Reputation: 129
I have a column with time format as ie 1200, how could I change in that format 12:00:00 ?
df['start_time'] = pd.to_datetime(df.start_time, format='%H:%M:%S')
Using the above I took the following error
ValueError: time data u'1200' does not match format '%H:%M' (match)
Any ideas?
Upvotes: 1
Views: 83
Reputation: 863531
Use to_datetime
with strftime
:
df['start_time'] = pd.to_datetime(df.start_time, format='%H%M').dt.strftime('%H:%M:%S')
Upvotes: 1