Skip to content

Commit 2c2809d

Browse files
committed
Merge pull request #7341 from cpcloud/hayd-gh2073
FIX: resample with fill_method and how #2073
2 parents 19c29ec + 34a4b4c commit 2c2809d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

doc/source/v0.14.1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Bug Fixes
8989
~~~~~~~~~
9090

9191
- Bug in ``Index.min`` and ``max`` doesn't handle ``nan`` and ``NaT`` properly (:issue:`7261`)
92+
- Bug in ``resample`` where ``fill_method`` was ignored if you passed ``how`` (:issue:`7261`)
9293
- Bug in ``TimeGrouper`` doesn't exclude column specified by ``key`` (:issue:`7227`)
9394
- Bug in ``DataFrame`` and ``Series`` bar and barh plot raises ``TypeError`` when ``bottom``
9495
and ``left`` keyword is specified (:issue:`7226`)

pandas/tseries/resample.py

+5
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ def _resample_timestamps(self):
252252
# downsample
253253
grouped = obj.groupby(grouper, axis=self.axis)
254254
result = grouped.aggregate(self._agg_method)
255+
# GH2073
256+
if self.fill_method is not None:
257+
result = result.fillna(method=self.fill_method,
258+
limit=self.limit)
259+
255260
else:
256261
# upsampling shortcut
257262
if self.axis:

pandas/tseries/tests/test_resample.py

+8
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,14 @@ def test_monthly_upsample(self):
869869
expected = expected.asfreq(targ, 'ffill').to_period()
870870
assert_series_equal(result, expected)
871871

872+
def test_fill_method_and_how_upsample(self):
873+
# GH2073
874+
s = Series(range(9),
875+
index=date_range('2010-01-01', periods=9, freq='Q'))
876+
last = s.resample('M', fill_method='ffill')
877+
both = s.resample('M', how='last', fill_method='ffill').astype('int64')
878+
assert_series_equal(last, both)
879+
872880
def test_weekly_upsample(self):
873881
targets = ['D', 'B']
874882

0 commit comments

Comments
 (0)