Skip to content

FIX: resample with fill_method and how #2073 #7341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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