'Pandas converting date time in string to datetime format
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'
Solution 1:[1]
Solution 2:[2]
Yes, you've used the wrong format for the year.
pd.to_datetime(df["Datetime"], format="%Y-%m-%d %H:%M:%S")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rahmat Fathoni |
| Solution 2 | Mattew |
