1

I know this seems like a duplicated question (and it kinda is), but previous answers didn't let me achieve what I'm looking for. I have a date Series with the following format:

     date
 Jun 13 14:46
 Jun 13 17:11

And so, I wanted to turn it into a datetime object. I did the following:

pd.to_datetime(df.date, format='%b %d %I:%M')

Which based on this question should be enough: Convert custom date formats in pandas

But, I'm still getting ValueError: time data 'Jun 13 14:46' does not match format '%b %d %I:%M' (match)

What am I missing?

Thanks

1 Answer 1

4

try pd.to_datetime(df.date, format='%b %d %H:%M')

%I is for a 12-hour clock.

%H is for a 24-hour clock.

Sign up to request clarification or add additional context in comments.

2 Comments

Damn. Thanks, that solves the issue! Do you know where can I find the meaning of all the date FormatString? I wasn't able to find them
in the docs for the datetime.strptime function: docs.python.org/3/library/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.