Skip to content

Commit

Permalink
FIX resample with fill_method and how pandas-dev#2073
Browse files Browse the repository at this point in the history
DOC add to release notes
  • Loading branch information
hayd authored and cpcloud committed Jun 4, 2014
1 parent 89983c3 commit 34a4b4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
5 changes: 5 additions & 0 deletions pandas/tseries/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions pandas/tseries/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down

0 comments on commit 34a4b4c

Please sign in to comment.