pythonweb
pythonweb

Reputation: 1073

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:

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?

Upvotes: 0

Views: 423

Answers (1)

BENY
BENY

Reputation: 323366

That is beacuse there is no 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. which means the clock had been set forward 15mins

Upvotes: 1

Related Questions