【问题标题】:Datetime Automatically Converted to Int日期时间自动转换为 Int
【发布时间】:2021-11-10 11:45:50
【问题描述】:

我有一个包含日期时间数据的系列。

当我想使用Series.unique().tolist()时,似乎日期时间自动转换为int。

请看下面的例子。我现在意识到没有必要,因为我可以遍历 Series.unique(),但出于好奇,有人知道为什么吗?

谢谢你????

【问题讨论】:

    标签: python python-3.x pandas numpy datetime


    【解决方案1】:

    我猜你可能会找到答案here

    长话短说:您正在尝试从 numpy.datetime64 类型(.unique() 的输出)转换,这在原版 python 中不存在,因此它被转换为 int。

    解决方法是使用list():

    list(sch['Datetime_sch'].unique())
    

    【讨论】:

      猜你喜欢
      • 2013-07-25
      • 1970-01-01
      • 1970-01-01
      • 2012-05-29
      • 1970-01-01
      • 2012-04-30
      • 2019-03-07
      • 2022-01-09
      相关资源
      最近更新 更多