Skip to content

!I fix for BUG: resample with tz-aware: Values falls after last bin #15549 #18336

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
wants to merge 10 commits into from
5 changes: 5 additions & 0 deletions pandas/tests/tseries/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2670,6 +2670,11 @@ def test_resample_weekly_bug_1726(self):
# it works!
df.resample('W-MON', closed='left', label='left').first()

def test_resample_tz_aware_bug_15549(self):
index = pd.DatetimeIndex([1450137600000000000, 1474059600000000000], tz='UTC').tz_convert('America/Chicago')
df = pd.DataFrame([1, 2], index=index)
df.resample('12h', closed='right', label='right').last().ffill()

def test_resample_bms_2752(self):
# GH2753
foo = pd.Series(index=pd.bdate_range('20000101', '20000201'))
Expand Down
5 changes: 1 addition & 4 deletions pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1944,10 +1944,7 @@ def _generate_regular_range(start, end, periods, offset):
stride = offset.nanos
if periods is None:
b = Timestamp(start).value
# cannot just use e = Timestamp(end) + 1 because arange breaks when
# stride is too large, see GH10887
e = (b + (Timestamp(end).value - b) // stride * stride +
stride // 2 + 1)
e = (Timestamp(end).value + (stride//2) + 1)
# end.tz == start.tz by this point due to _generate implementation
tz = start.tz
elif start is not None:
Expand Down