I was working with some data in pandas as after saving it to csv
it changed the format from 00:31:24.904000
timedelta64[ns]
to 0 days 00:31:24.904000
Object
.
0 0 days 00:25:20.835688000
1 0 days 00:01:44.004000000
2 0 days 00:18:29.023000000
3 0 days 00:09:06.633000000
4 0 days 00:02:16.826000000
...
6004 0 days 00:00:00.000000000
6005 0 days 00:31:24.904000000
6006 0 days 00:02:31.637000000
6007 0 days 00:03:40.214000000
6008 0 days 00:01:26.577000000
Name: Time, Length: 6009, dtype: object
How can I convert it back to timedelta or some other date/time related format? How can I avoid such conversion during saving to csv
How can I convert it back to timedelta or some other date/time related format?
df['Time'] = pd.to_timedelta(df['Time'])
How can I avoid such conversion during saving to csv
It is not possible, because in csv all data are strings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.