Skip to content

Commit

Permalink
BUG: Fix #20744. loffset ignored in resample ffill (#20884)
Browse files Browse the repository at this point in the history
  • Loading branch information
johncant authored and jreback committed May 1, 2018
1 parent c8fcfcb commit f799916
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,7 @@ Groupby/Resample/Rolling
- Bug in :func:`DataFrameGroupBy.cumsum` and :func:`DataFrameGroupBy.cumprod` when ``skipna`` was passed (:issue:`19806`)
- Bug in :func:`DataFrame.resample` that dropped timezone information (:issue:`13238`)
- Bug in :func:`DataFrame.groupby` where transformations using ``np.all`` and ``np.any`` were raising a ``ValueError`` (:issue:`20653`)
- Bug in :func:`DataFrame.resample` where ``ffill``, ``bfill``, ``pad``, ``backfill``, ``fillna``, ``interpolate``, and ``asfreq`` were ignoring ``loffset``. (:issue:`20744`)

Sparse
^^^^^^
Expand Down
1 change: 1 addition & 0 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ def _upsample(self, method, limit=None, fill_value=None):
result = obj.reindex(res_index, method=method,
limit=limit, fill_value=fill_value)

result = self._apply_loffset(result)
return self._wrap_result(result)

def _wrap_result(self, result):
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,19 @@ def test_resample_loffset(self):
expected = ser.resample('w-sun', loffset=-bday).last()
assert result.index[0] - bday == expected.index[0]

def test_resample_loffset_upsample(self):
# GH 20744
rng = date_range('1/1/2000 00:00:00', '1/1/2000 00:13:00', freq='min')
s = Series(np.random.randn(14), index=rng)

result = s.resample('5min', closed='right', label='right',
loffset=timedelta(minutes=1)).ffill()
idx = date_range('1/1/2000', periods=4, freq='5min')
expected = Series([s[0], s[5], s[10], s[-1]],
index=idx + timedelta(minutes=1))

assert_series_equal(result, expected)

def test_resample_loffset_count(self):
# GH 12725
start_time = '1/1/2000 00:00:00'
Expand Down

0 comments on commit f799916

Please sign in to comment.