I have a dataframe with one column 'time', which is the object int64
and looks like this:
time
202003180001043
202003180001044
And which should be converted to a datetime column:
time
2020-03-18 00:01:043
2020-03-18 00:01:044
When I run the command:
df['time'] = pd.to_datetime(df['time'], format='%Y%m%d%I%M%S')
I get the error: ValueError: unconverted data remains: 04
How canI include the last numbers?
Problem is %I
is for hour in 12hours format, so failed. Need %H
for hours in 24hours format:
df['time'] = pd.to_datetime(df['time'], format='%Y%m%d%H%M%S%f')
print (df)
time
0 2020-03-18 00:01:04.300
1 2020-03-18 00:01:04.400
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.