大熊猫无法比较偏移初始化和偏移感知日期时间

时间:2017-09-19 08:18:59

标签: python-2.7 pandas

我喜欢这样的。

df['Time']
2017-08-06 11:00:00+00:00
2017-08-08 15:00:00+00:00
2017-08-10 04:00:00+00:00
2017-08-12 23:00:00+00:00
2017-08-08 15:00:00+00:00

我想用条件

来切片
mask1=df['Time'] > datetime.datetime.strptime('2017-08-12', "%Y-%m-%d")

我得到了一个错误 无法比较偏移初始化和偏移感知日期时间 不知何故,我必须将df ['时间']转换为偏移 - 天真。 请帮我解决这个问题。

1 个答案:

答案 0 :(得分:2)

似乎你需要:

df['Time'] = df['Time'].dt.tz_localize(None)

或者:

df['Time'] = df['Time'].dt.tz_convert(None)

或者:

df['Time'] = df['Time'].astype('datetime64[ns]')

另见tz aware dtypes

相关问题