diff --git a/doc/source/release.rst b/doc/source/release.rst index d4ff1e0aa1e24..51833dd4d2e3b 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -176,6 +176,7 @@ Bug Fixes - Bug in ``str.split`` when passed ``pat=None`` and ``n=1`` (:issue:`6466`) - Bug in ``io.data.DataReader`` when passed ``"F-F_Momentum_Factor"`` and ``data_source="famafrench"`` (:issue:`6460`) - Bug in ``sum`` of a ``timedelta64[ns]`` series (:issue:`6462`) +- Bug in ``resample`` with a timezone and certain offsets (:issue:`6397`) pandas 0.13.1 ------------- diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index a8dacbe40aac0..1092b46ea6560 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -1067,7 +1067,13 @@ def _can_fast_union(self, other): left_end = left[-1] # Only need to "adjoin", not overlap - return (right_start == left_end + offset) or right_start in left + try: + return (right_start == left_end + offset) or right_start in left + except (ValueError): + + # if we are comparing an offset that does not propogate timezones + # this will raise + return False def _fast_union(self, other): if len(other) == 0: diff --git a/pandas/tseries/tests/test_resample.py b/pandas/tseries/tests/test_resample.py index 2d4d8ccfa1a98..23b8905b2ae9a 100644 --- a/pandas/tseries/tests/test_resample.py +++ b/pandas/tseries/tests/test_resample.py @@ -973,6 +973,18 @@ def test_resample_tz_localized(self): expected = Series([1.5], index=ex_index) assert_series_equal(result, expected) + # GH 6397 + # comparing an offset that doesn't propogate tz's + rng = date_range('1/1/2011', periods=20000, freq='H') + rng = rng.tz_localize('EST') + ts = DataFrame(index=rng) + ts['first']=np.random.randn(len(rng)) + ts['second']=np.cumsum(np.random.randn(len(rng))) + expected = DataFrame({ 'first' : ts.resample('A',how=np.sum)['first'], + 'second' : ts.resample('A',how=np.mean)['second'] },columns=['first','second']) + result = ts.resample('A', how={'first':np.sum, 'second':np.mean}).reindex(columns=['first','second']) + assert_frame_equal(result,expected) + def test_closed_left_corner(self): # #1465 s = Series(np.random.randn(21),