Skip to content

Commit 940fb22

Browse files
committed
Avoid AmbiguousTimeError on groupby
1 parent 45543ec commit 940fb22

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

pandas/tseries/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def _generate(cls, start, end, periods, name, offset,
439439
tz = tz.localize(date.replace(tzinfo=None)).tzinfo
440440

441441
if tz is not None and inferred_tz is not None:
442-
if not inferred_tz == tz:
442+
if not tslib.get_timezone(inferred_tz) == tslib.get_timezone(tz):
443443
raise AssertionError("Inferred time zone not equal to passed "
444444
"time zone")
445445

pandas/tseries/resample.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,8 +1284,7 @@ def _adjust_dates_anchored(first, last, offset, closed='right', base=0):
12841284
# See https://github.com/pandas-dev/pandas/issues/8683
12851285

12861286
first_tzinfo = first.tzinfo
1287-
first = first.tz_localize(None)
1288-
last = last.tz_localize(None)
1287+
last_tzinfo = last.tzinfo
12891288
start_day_nanos = first.normalize().value
12901289

12911290
base_nanos = (base % offset.n) * offset.nanos // offset.n
@@ -1320,11 +1319,9 @@ def _adjust_dates_anchored(first, last, offset, closed='right', base=0):
13201319
else:
13211320
lresult = last.value + offset.nanos
13221321

1323-
# return (Timestamp(fresult, tz=first.tz),
1324-
# Timestamp(lresult, tz=last.tz))
1322+
return (Timestamp(fresult, tz=first_tzinfo),
1323+
Timestamp(lresult, tz=last_tzinfo))
13251324

1326-
return (Timestamp(fresult).tz_localize(first_tzinfo),
1327-
Timestamp(lresult).tz_localize(first_tzinfo))
13281325

13291326

13301327
def asfreq(obj, freq, method=None, how=None, normalize=False):

0 commit comments

Comments
 (0)