Reputation: 337
I have a dataframe
timestamp
2020-08-26
2020-08-27
2020-08-28
I want it to look like this
timestamp
2020-08-26 00:00:00
2020-08-27 00:00:00
2020-08-28 00:00:00
I tried
df['timestamp'] = df['timestamp'].apply(lambda x: dt.datetime.strftime(x, '%Y-%m-%d %H:%M:%S'))
but it gives an issue TypeError: descriptor 'strftime' for 'datetime.date' objects doesn't apply to a 'str' object
Appreciate your help
Upvotes: 1
Views: 5299
Reputation: 5204
try this,
df['timestamp'] = pd.to_datetime(df['timestamp']).dt.strftime('%Y-%m-%d %H:%M:%S')
Upvotes: 3