Skip to content
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/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ Groupby/resample/rolling
- Bug in :meth:`DataFrame.groupby` not offering selection by column name when ``axis=1`` (:issue:`27614`)
- Bug in :meth:`DataFrameGroupby.agg` not able to use lambda function with named aggregation (:issue:`27519`)
- Bug in :meth:`DataFrame.groupby` losing column name information when grouping by a categorical column (:issue:`28787`)
- Bug in :meth:`DataFrameGroupBy.rolling().quantile()` ignoring ``interpolation`` keyword argument (:issue:`28779`)

Reshaping
^^^^^^^^^
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,9 @@ def f(arg, *args, **kwargs):
interpolation,
)

return self._apply(f, "quantile", quantile=quantile, **kwargs)
return self._apply(
f, "quantile", quantile=quantile, interpolation=interpolation, **kwargs
)

_shared_docs[
"cov"
Expand Down
25 changes: 20 additions & 5 deletions pandas/tests/window/test_grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def test_rolling(self):
r = g.rolling(window=4)

for f in ["sum", "mean", "min", "max", "count", "kurt", "skew"]:

result = getattr(r, f)()
expected = g.apply(lambda x: getattr(x.rolling(4), f)())
tm.assert_frame_equal(result, expected)
Expand All @@ -70,8 +69,16 @@ def test_rolling(self):
expected = g.apply(lambda x: getattr(x.rolling(4), f)(ddof=1))
tm.assert_frame_equal(result, expected)

result = r.quantile(0.5)
expected = g.apply(lambda x: x.rolling(4).quantile(0.5))
@pytest.mark.parametrize(
"interpolation", ["linear", "lower", "higher", "midpoint", "nearest"]
)
def test_rolling_quantile(self, interpolation):
g = self.frame.groupby("A")
r = g.rolling(window=4)
result = r.quantile(0.4, interpolation=interpolation)
expected = g.apply(
lambda x: x.rolling(4).quantile(0.4, interpolation=interpolation)
)
tm.assert_frame_equal(result, expected)

def test_rolling_corr_cov(self):
Expand Down Expand Up @@ -142,8 +149,16 @@ def test_expanding(self):
expected = g.apply(lambda x: getattr(x.expanding(), f)(ddof=0))
tm.assert_frame_equal(result, expected)

result = r.quantile(0.5)
expected = g.apply(lambda x: x.expanding().quantile(0.5))
@pytest.mark.parametrize(
"interpolation", ["linear", "lower", "higher", "midpoint", "nearest"]
)
def test_expanding_quantile(self, interpolation):
g = self.frame.groupby("A")
r = g.expanding()
result = r.quantile(0.4, interpolation=interpolation)
expected = g.apply(
lambda x: x.expanding().quantile(0.4, interpolation=interpolation)
)
tm.assert_frame_equal(result, expected)

def test_expanding_corr_cov(self):
Expand Down