Skip to content

Commit f799916

Browse files
johncantjreback
authored andcommitted
BUG: Fix #20744. loffset ignored in resample ffill (#20884)
1 parent c8fcfcb commit f799916

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

doc/source/whatsnew/v0.23.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@ Groupby/Resample/Rolling
12061206
- Bug in :func:`DataFrameGroupBy.cumsum` and :func:`DataFrameGroupBy.cumprod` when ``skipna`` was passed (:issue:`19806`)
12071207
- Bug in :func:`DataFrame.resample` that dropped timezone information (:issue:`13238`)
12081208
- Bug in :func:`DataFrame.groupby` where transformations using ``np.all`` and ``np.any`` were raising a ``ValueError`` (:issue:`20653`)
1209+
- Bug in :func:`DataFrame.resample` where ``ffill``, ``bfill``, ``pad``, ``backfill``, ``fillna``, ``interpolate``, and ``asfreq`` were ignoring ``loffset``. (:issue:`20744`)
12091210

12101211
Sparse
12111212
^^^^^^

pandas/core/resample.py

+1
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ def _upsample(self, method, limit=None, fill_value=None):
967967
result = obj.reindex(res_index, method=method,
968968
limit=limit, fill_value=fill_value)
969969

970+
result = self._apply_loffset(result)
970971
return self._wrap_result(result)
971972

972973
def _wrap_result(self, result):

pandas/tests/test_resample.py

+13
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,19 @@ def test_resample_loffset(self):
11821182
expected = ser.resample('w-sun', loffset=-bday).last()
11831183
assert result.index[0] - bday == expected.index[0]
11841184

1185+
def test_resample_loffset_upsample(self):
1186+
# GH 20744
1187+
rng = date_range('1/1/2000 00:00:00', '1/1/2000 00:13:00', freq='min')
1188+
s = Series(np.random.randn(14), index=rng)
1189+
1190+
result = s.resample('5min', closed='right', label='right',
1191+
loffset=timedelta(minutes=1)).ffill()
1192+
idx = date_range('1/1/2000', periods=4, freq='5min')
1193+
expected = Series([s[0], s[5], s[10], s[-1]],
1194+
index=idx + timedelta(minutes=1))
1195+
1196+
assert_series_equal(result, expected)
1197+
11851198
def test_resample_loffset_count(self):
11861199
# GH 12725
11871200
start_time = '1/1/2000 00:00:00'

0 commit comments

Comments
 (0)