指定熊猫的时区to_datetime函数

问题描述

当我在数据上使用pd.to_datetime函数时,如下所示,我得到了UTC时区感知序列。我知道tz_convert函数,但我认为它不适合我的目的。

我的时间在美国中部时区。如果我没有指定,那么我的21:00 CDT被假定为21:00 UTC,而tz_convert会错误地给我16:00-5:00。也许我只是对时间的表示感到困惑,但是据我所知,它会错误地将21:00 CDT表示为16:00 CDT。

如果我可以指定在转换时间列时要使用的时区,我不认为这会成为问题。或者,如果仅存在一种无需进行转换即可设置时区的方法。下面是一个示例:

TextFormFeild(decoration: InputDecoration(prefixIcon: //your icon),),

此输出为:

df = pd.DataFrame([])
theseAreCentralTime = ['2015-04-24T23:48:28Z','2015-04-24T23:40:59Z','2015-04-24T23:48:28Z']
df['time'] = theseAreCentralTime
df['time'] = pd.to_datetime(df['time'])
print(df['time'].dt.tz)
print(df['time'])
df['time'] = df['time'].dt.tz_convert('US/Central')
print(df['time'].dt.tz)
print(df['time'])

我希望看到的时间是:

UTC
0   2015-04-24 23:48:28+00:00
1   2015-04-24 23:40:59+00:00
2   2015-04-24 23:48:28+00:00
Name: time,dtype: datetime64[ns,UTC]
US/Central
0   2015-04-24 18:48:28-05:00
1   2015-04-24 18:40:59-05:00
2   2015-04-24 18:48:28-05:00
Name: time,US/Central]

在此先感谢您的帮助

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)