Skip to content

BUG: Adding offset produces NonExistentTimeError #36165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rhshadrach opened this issue Sep 6, 2020 · 7 comments
Closed

BUG: Adding offset produces NonExistentTimeError #36165

rhshadrach opened this issue Sep 6, 2020 · 7 comments
Labels
Bug Unreliable Test Unit tests that occasionally fail

Comments

@rhshadrach
Copy link
Member

In #36160, Travis had the following failure:

pandas/tests/tseries/offsets/test_offsets_properties.py:88: 
[snip]
---------------------------------- Hypothesis ----------------------------------
Falsifying example: test_on_offset_implementations(
    dt=datetime.datetime(1900, 1, 1, 0, 0, tzinfo=tzfile('/usr/share/zoneinfo/Iceland')),
    offset=<96 * MonthBegins>,
)
You can reproduce this example by temporarily adding @reproduce_failure('5.29.0', b'AAEAMgAAAAAAAAAAAABgAA==') as a decorator on your test case

Can reproduce with:

from datetime import datetime
import pytz
from pandas.tseries.offsets import MonthBegin

dt = datetime(1900, 1, 1, 0, 0, tzinfo=pytz.timezone('Iceland'))
offset = MonthBegin(96)
dt + offset

which produces the trace:

  File "pandas/_libs/tslibs/offsets.pyx", line 422, in pandas._libs.tslibs.offsets.BaseOffset.__add__
  File "pandas/_libs/tslibs/offsets.pyx", line 424, in pandas._libs.tslibs.offsets.BaseOffset.__add__
  File "pandas/_libs/tslibs/offsets.pyx", line 172, in pandas._libs.tslibs.offsets.apply_wraps.wrapper
  File "pandas/_libs/tslibs/timestamps.pyx", line 1317, in pandas._libs.tslibs.timestamps.Timestamp.tz_localize
  File "pandas/_libs/tslibs/tzconversion.pyx", line 63, in pandas._libs.tslibs.tzconversion.tz_localize_to_utc_single
  File "pandas/_libs/tslibs/tzconversion.pyx", line 319, in pandas._libs.tslibs.tzconversion.tz_localize_to_utc
pytz.exceptions.NonExistentTimeError: 1908-01-01 00:00:00

Not sure if this is a bug or an invalid input.

@rhshadrach rhshadrach added Bug Unreliable Test Unit tests that occasionally fail Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 6, 2020
@satyabansahoo2000
Copy link

@rhshadrach It's seems to be an bad input. I tried the code offset = MonthBegin(n=90) which works. So, except n=96, it works with all other values.

@mroeschke
Copy link
Member

I think the root issue stems from #28610.

datetime object + Offset object does not have any handling whether the resulting timestamp if ambiguous or nonexsitent

@rhshadrach
Copy link
Member Author

Agreed @mroeschke and @hemraj4545, but the question for me is: why is this particular time nonexistent? It happens for me if the minutes are anywhere in 1 to 27, and only in the Iceland timezone. I was also under the expectation that

datetime(1908, 1, 1, 0, 0, tzinfo=pytz.timezone('Iceland'))

would raise as well, but that works fine for me.

@rhshadrach
Copy link
Member Author

Okay - I found it here:

The time zone of Iceland is UT0 (i.e. the same as Greenwich, UK), but Iceland did not adopt the global time zone until January 1908, when GMT‐1 was adopted.

That makes this a duplicate of #28610.

@rhshadrach rhshadrach removed the Needs Triage Issue that has not been reviewed by a pandas team member label Sep 7, 2020
@germainvelard
Copy link

Hi,
To me this issue is not closed.
I have the issue with the operation datetime object + Offset object which leads to "pytz.exceptions.NonExistentTimeError: 2019-03-31 02:00:00"
This is due to the fact that this hour is not existent in western Europe due to DST

@rhshadrach
Copy link
Member Author

@germainvelard This issue is closed not because it has been resolved, but rather because it has been found to be a duplicate of another issue as noted above. It seems to me that issue covers what you mention as well, but please let me know if you disagree here.

@germainvelard
Copy link

Hi @rhshadrach, thanks for your reply.
It seemed to me that the linked issue was also closed but I was mistaken !
Apologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Unreliable Test Unit tests that occasionally fail
Projects
None yet
Development

No branches or pull requests

4 participants