-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Closed
Copy link
Labels
BugNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team memberTimestamppd.Timestamp and associated methodspd.Timestamp and associated methods
Description
dtstr = '11/06/2011 01:00'
tz = "US/Eastern"
>>> pd.Timestamp(dtstr, tz=tz)
Timestamp('2011-11-06 01:00:00-0500', tz='US/Eastern')
>>> pd.Timestamp(dtstr).tz_localize(tz)
pytz.exceptions.AmbiguousTimeError: Cannot infer dst time from 2011-11-06 01:00:00, try using the 'ambiguous' argument
I expected these to be equivalent. Am I wrong to expect that?
Looks like the constructor version goes through _localize_pydatetime (then pytz's tz.localize) instead of Timestamp.tz_localize which apparently doesn't find this case ambiguous.
Update: passing is_dst=None
to tz.localize
in _localize_pydatetime causes the constructor version to raise like I expected.
Update 2: passing is_dst=None as above breaks two tests in the test suite: test_dti_tz_localize_ambiguous_infer and test_fallback_singular
Metadata
Metadata
Assignees
Labels
BugNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team memberTimestamppd.Timestamp and associated methodspd.Timestamp and associated methods