Reputation: 2556
I have a pandas series with DateTime in the 2020-01-05D00:00:00.000000000
string format and I want to convert it into the date
format.
I tried pd.to_datetime(website_activity['time'])
but it is giving me the following error:
ParserError: Unknown string format: 2020-01-05D00:00:00.000000000
What is the right format for such a DateTime stamp? Many thanks in advance!
Upvotes: 1
Views: 89
Reputation: 862641
Add custom string to parameter format
in to_datetime
, check https://strftime.org/:
website_activity = pd.DataFrame({'time':['2020-01-05D00:00:00.000000000',
'2021-01-05D00:00:00.000000000']})
website_activity['time'] = (pd.to_datetime(website_activity['time'],
format='%Y-%m-%dD%H:%M:%S.%f'))
print (website_activity)
time
0 2020-01-05
1 2021-01-05
Upvotes: 2