diff --git a/pandas/tests/tseries/test_resample.py b/pandas/tests/tseries/test_resample.py index 1535bd665fe8b..56953dc378965 100755 --- a/pandas/tests/tseries/test_resample.py +++ b/pandas/tests/tseries/test_resample.py @@ -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')) diff --git a/pandas/tseries/resample.py b/pandas/tseries/resample.py index 75e550a065fd2..f759cd9613a81 100755 --- a/pandas/tseries/resample.py +++ b/pandas/tseries/resample.py @@ -1149,12 +1149,15 @@ def _get_time_bins(self, ax): binner = labels = DatetimeIndex( data=[], freq=self.freq, name=ax.name) return binner, [], labels - + + tz = ax.tz + if tz: + ax = ax.tz_convert('UTC') + first, last = ax.min(), ax.max() first, last = _get_range_edges(first, last, self.freq, closed=self.closed, base=self.base) - tz = ax.tz # GH #12037 # use first/last directly instead of call replace() on them # because replace() will swallow the nanosecond part @@ -1163,8 +1166,8 @@ def _get_time_bins(self, ax): binner = labels = DatetimeIndex(freq=self.freq, start=first, end=last, - tz=tz, - name=ax.name) + tz='UTC', + name=ax.name).tz_convert(tz) # a little hack trimmed = False