I'm trying to convert a datetime column back to a string in Pandas dataframe.
the syntax I have so far is:
all_data['Order Day new'] = dt.date.strftime(all_data['Order Day new'], '%d/%m/%Y')
but this returns the error:
descriptor 'strftime' requires a 'datetime.date' object but received a 'Series'.
Can anyone tell me where I'm going wrong.
Best Answer
If you're using version
0.17.0
or higher then you can call this using.dt.strftime
which is vectorised:** If your pandas version is older than
0.17.0
then you have to callapply
and pass the data tostrftime
:You can't call
strftime
on the column as it doesn't understandSeries
as a param hence the error