熊猫日期时间转换问题

时间:2019-11-16 19:28:57

标签: python pandas datetime

在将时间戳的熊猫列转换为“月”时感到困惑。我有一系列的日期时间,我只是想提取月份。得到了以下尴尬的结果。

最大时间戳

  

a =(df [df ['sr_process_year'] == 2019] ['sr_open_date'])。max()

a = 2019-08-23 20:59:12

日期时间转换

  

b = a.month

b = 8

熊猫.dt。月转换

  

c =(df [df ['sr_process_year'] == 2019] ['sr_open_date'])。dt.month

c.max()= 12 !! ??

非常感谢您提出意见,为什么.dt.month方法确实提供了不准确的结果。谢谢!

0 个答案:

没有答案