3

I am trying to convert a pandas column to datetime. This is my error message.

ValueError: time data '01-JUN-17 00:00:00' does not match format '%d-%b-%y %H.%M.%S' (match)

This is my code :

df['dayofservice'] =  pd.to_datetime(df['dayofservice'], format = '%d-%b-%y %H.%M.%S')

I have read this documentation to ensure my format is correct : https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

It's still not working for me.

0

2 Answers 2

4

pandas is man/woman enough to parse this without a format field:

In[90]:
pd.to_datetime('01-JUN-17 00:00:00')

Out[90]: Timestamp('2017-06-01 00:00:00')

So this should work:

df['dayofservice'] =  pd.to_datetime(df['dayofservice'])
Sign up to request clarification or add additional context in comments.

Comments

0

Change . to : in times like:

df['dayofservice'] =  pd.to_datetime(df['dayofservice'], format = '%d-%b-%y %H:%M:%S')

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.