西班牙日期时间返回NaT [英] spanish datetime return NaT
问题描述
我有一个日期列,其格式为 19 dic 2020 23:59
(西班牙语日期)我想将其转换为 datetime
类型.
I have a date column with the format 19 dic 2020 23:59
(spanish date)
and I want to convert it into a datetime
type.
df["Time"] = pd.to_datetime(df.Time, format='%d %b %Y %H:%M', errors = "coerce")
运行代码列后,正确的类型为 datetime
,但其中仅包含NaT值.
After running the code column is the right type datetime
but it only contains NaT values.
我在做什么错了?
推荐答案
我认为这是与熊猫函数相关的错误,在您的情况下,该函数不支持其他语言环境,例如 es_ES
.我建议按照这两个答案中的描述更改语言环境或进行迭代.第一个建议通过 datetime
使用语言环境更改,第二个建议使用替换.
I believe this is an error that is associated with pandas' function not supporting other locales such as es_ES
as in your case. I would recommend changing the locale or iterating as is described in these two answers. The first uses a locale change via datetime
and the second recommends using substitution.
这篇关于西班牙日期时间返回NaT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!