[英]Pandas converting date time in string to datetime format
I have a column in Pandas dataframe which is a datetime entry column in string.我在 Pandas dataframe 中有一列,它是字符串中的日期时间条目列。 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'
Try %Y,试试 %Y,
this is the cheatsheet: https://strftime.org/这是备忘单: https://strftime.org/
Yes, you've used the wrong format for the year.是的,您使用了错误的年份格式。
pd.to_datetime(df["Datetime"], format="%Y-%m-%d %H:%M:%S")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.