Issue
I would like to convert these values to datetime type but I keep getting an error.
0 2021-11-12 04:08:13:427
17 2021-11-12 04:13:15:044
34 2021-11-12 04:18:17:817
51 2021-11-12 04:23:19:887
68 2021-11-12 04:28:21:409
the code i used:
df['Time'] = pd.to_datetime(df['Time'])
the error:
Error ParserError: Unknown string format: 2021-11-12 04:08:13:427
Solution
Try mentioning format. The values also seem to have some trailing spaces.
df['Time'] = pd.to_datetime(df['Time'].str.strip(), format="%Y-%m-%d %H:%M:%S:%f")
Answered By - Ashok Thakur
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.