简体   繁体   English

熊猫date_range与时区错误,可能是错误?

[英]Pandas date_range with timezone error, possible bug?

So I am trying this code: 所以我正在尝试这段代码:

observed_df_new_index = pd.date_range('1962-01-01', '2018-01-01',
                                      freq='1D', tz='Asia/Kathmandu')

and I get this error: 我得到这个错误:

File "pandas\_libs\tslibs\conversion.pyx", line 989, in pandas._libs.tslibs.conversion.tz_localize_to_utc
pytz.exceptions.NonExistentTimeError: 1986-01-01 00:00:00

Which made me think that there is something wierd about Jan 1, 1986. So then I tried this: 这使我认为1986年1月1日有些奇怪。于是,我尝试了一下:

UTC = pytz.timezone('UTC')
asia = pytz.timezone('Asia/Kathmandu')

x = datetime.datetime(1986, 1, 1, 0, 0, 0, tzinfo=UTC)
print(x.replace(tzinfo=asia))

and it works fine. 而且效果很好。 Is there something that I am doing wrong or does it just not like that date and particular timezone? 我有做错什么吗?还是不只是那个日期和特定的时区?

That is beacuse there is no 1986-01-01 00:00:00 那是因为没有1986-01-01 00:00:00

After 1985-12-31 11:59:59 PM , Clocks were jumped to 1986-01-01 12:15:00 AM , so 1986-01-01 00:00:00 just being skip. 1985-12-31 11:59:59 PM ,时钟跳到1986-01-01 12:15:00 AM ,所以1986-01-01 00:00:00被跳过了。 which means the clock had been set forward 15mins 这表示时钟已提前15分钟

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM