Skip to content

Commit 352445c

Browse files
committed
BUG: RollingGroupBy.quantile ignores interpolation keyword argument (#28779)
1 parent 5c36aa1 commit 352445c

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ Groupby/resample/rolling
427427
- Bug in :meth:`DataFrame.groupby` not offering selection by column name when ``axis=1`` (:issue:`27614`)
428428
- Bug in :meth:`DataFrameGroupby.agg` not able to use lambda function with named aggregation (:issue:`27519`)
429429
- Bug in :meth:`DataFrame.groupby` losing column name information when grouping by a categorical column (:issue:`28787`)
430+
- Bug in :meth:`RollingGroupby.quantile` ignoring ``interpolation`` keyword argument (:issue:`28779`)
430431

431432
Reshaping
432433
^^^^^^^^^

pandas/core/window/rolling.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,9 @@ def f(arg, *args, **kwargs):
14991499
interpolation,
15001500
)
15011501

1502-
return self._apply(f, "quantile", quantile=quantile, **kwargs)
1502+
return self._apply(
1503+
f, "quantile", quantile=quantile, interpolation=interpolation, **kwargs
1504+
)
15031505

15041506
_shared_docs[
15051507
"cov"

pandas/tests/window/test_grouper.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def test_rolling(self):
5959
r = g.rolling(window=4)
6060

6161
for f in ["sum", "mean", "min", "max", "count", "kurt", "skew"]:
62-
6362
result = getattr(r, f)()
6463
expected = g.apply(lambda x: getattr(x.rolling(4), f)())
6564
tm.assert_frame_equal(result, expected)
@@ -69,9 +68,10 @@ def test_rolling(self):
6968
expected = g.apply(lambda x: getattr(x.rolling(4), f)(ddof=1))
7069
tm.assert_frame_equal(result, expected)
7170

72-
result = r.quantile(0.5)
73-
expected = g.apply(lambda x: x.rolling(4).quantile(0.5))
74-
tm.assert_frame_equal(result, expected)
71+
for f in ["linear", "lower", "higher", "midpoint", "nearest"]:
72+
result = r.quantile(0.4, interpolation=f)
73+
expected = g.apply(lambda x: x.rolling(4).quantile(0.4, interpolation=f))
74+
tm.assert_frame_equal(result, expected)
7575

7676
def test_rolling_corr_cov(self):
7777
g = self.frame.groupby("A")
@@ -141,9 +141,10 @@ def test_expanding(self):
141141
expected = g.apply(lambda x: getattr(x.expanding(), f)(ddof=0))
142142
tm.assert_frame_equal(result, expected)
143143

144-
result = r.quantile(0.5)
145-
expected = g.apply(lambda x: x.expanding().quantile(0.5))
146-
tm.assert_frame_equal(result, expected)
144+
for f in ["linear", "lower", "higher", "midpoint", "nearest"]:
145+
result = r.quantile(0.4, interpolation=f)
146+
expected = g.apply(lambda x: x.expanding().quantile(0.4, interpolation=f))
147+
tm.assert_frame_equal(result, expected)
147148

148149
def test_expanding_corr_cov(self):
149150
g = self.frame.groupby("A")

0 commit comments

Comments
 (0)