0

I have a column in Pandas dataframe which is a datetime entry column in string. I have tried using the the syntax but it gives rise to this error.

Syntax

pd.to_datetime(df['Datetime'], format = '%y-%m-%d %H:%M:%S')
Error
time data '2020-11-01 16:23:12' does not match format '%y-%m-%d %H:%M:%S'
1
  • 2
    try it with capital Y (or don't put in format at all) Commented Feb 28, 2022 at 3:34

2 Answers 2

1

Yes, you've used the wrong format for the year.

pd.to_datetime(df["Datetime"], format="%Y-%m-%d %H:%M:%S")
Sign up to request clarification or add additional context in comments.

Comments

0

Try %Y,

this is the cheatsheet: https://strftime.org/

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.