I have csv file with format HH:MM:SS.Milisecond
06:37:46.200
06:37:46.600
06:37:47.300
I want convert that to
23866.200
23866.600
23867.300
How to do that in Pandas latest version (1.4)?
I've tried some answers from this forum, but they don't work on csv and latest version of Pandas.
CodePudding user response:
Assuming this input:
time
0 06:37:46.200
1 06:37:46.600
2 06:37:47.300
You can use pandas.Timedelta.total_seconds
:
pd.to_timedelta(df['time']).dt.total_seconds()
output:
0 23866.2
1 23866.6
2 23867.3
Name: time, dtype: float64