Reputation: 53
I have a pandas column with timestamp strings in the format '00:00:00.000' (hours, minutes, seconds, micro seconds). I would like to convert them to datetime
objects to work on the seconds.
I have seen many similar questions here for example. I am guessing that I should use strptime
but I couldn't figure out how.
Upvotes: 1
Views: 673
Reputation: 862406
If convert values to datetimes in pandas, also there is added some default date
by to_datetime
:
df['col'] = pd.to_datetime(df['col'], format='%H:%M:%S.%f')
If need avoid it convert values to timedeltas by to_timedelta
:
df['col'] = pd.to_timedelta(df['col'])
Upvotes: 1