ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

向右看齐 2023-01-11 08:59 418阅读 0赞

解决ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

报错代码

  1. pd.to_datetime(data['Formatted Date'], errors='coerce')

报错日志

  1. ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

解决办法

  1. pd.to_datetime(data['Formatted Date'], errors='coerce'utc=True)

utc=True

报错原因

to_datetime()转换失败,转换前类型为object,转换后类型应该是datetime64[ns, UTC])

欢迎大家交流学习,任何问题都可以留言

发表评论

表情:
评论列表 (有 0 条评论,418人围观)

还没有评论,来说两句吧...

相关阅读