diff --git a/doc/source/v0.14.1.txt b/doc/source/v0.14.1.txt index 20620f15944f0..b1e1f77d0b833 100644 --- a/doc/source/v0.14.1.txt +++ b/doc/source/v0.14.1.txt @@ -89,6 +89,7 @@ Bug Fixes ~~~~~~~~~ - Bug in ``Index.min`` and ``max`` doesn't handle ``nan`` and ``NaT`` properly (:issue:`7261`) +- Bug in ``resample`` where ``fill_method`` was ignored if you passed ``how`` (:issue:`7261`) - Bug in ``TimeGrouper`` doesn't exclude column specified by ``key`` (:issue:`7227`) - Bug in ``DataFrame`` and ``Series`` bar and barh plot raises ``TypeError`` when ``bottom`` and ``left`` keyword is specified (:issue:`7226`) diff --git a/pandas/tseries/resample.py b/pandas/tseries/resample.py index dd72a5245e7b2..812dd5aba71e0 100644 --- a/pandas/tseries/resample.py +++ b/pandas/tseries/resample.py @@ -252,6 +252,11 @@ def _resample_timestamps(self): # downsample grouped = obj.groupby(grouper, axis=self.axis) result = grouped.aggregate(self._agg_method) + # GH2073 + if self.fill_method is not None: + result = result.fillna(method=self.fill_method, + limit=self.limit) + else: # upsampling shortcut if self.axis: diff --git a/pandas/tseries/tests/test_resample.py b/pandas/tseries/tests/test_resample.py index 45d17052d904b..88bacb3d7b8ab 100644 --- a/pandas/tseries/tests/test_resample.py +++ b/pandas/tseries/tests/test_resample.py @@ -869,6 +869,14 @@ def test_monthly_upsample(self): expected = expected.asfreq(targ, 'ffill').to_period() assert_series_equal(result, expected) + def test_fill_method_and_how_upsample(self): + # GH2073 + s = Series(range(9), + index=date_range('2010-01-01', periods=9, freq='Q')) + last = s.resample('M', fill_method='ffill') + both = s.resample('M', how='last', fill_method='ffill').astype('int64') + assert_series_equal(last, both) + def test_weekly_upsample(self): targets = ['D', 'B']