Reputation: 686
I have a list of dates:
x = ['20200116, '20200117']
which i want to plot on x-axis. I used below code for formatting the list:
x = (datetime.datetime.strptime(date, '%Y%m%d').strftime('%m/%d/%Y') for date in x)
Expected output : a list with dates in '%m/%d/%Y' format but it returns an object. What am i doing wrong here?
Upvotes: 0
Views: 41
Reputation: 11376
Here x
variable is a generator object, either use list(x)
or [...]
instead of (...)
.
Upvotes: 1