Skip to content

Commit 8899204

Browse files
committed
TST Add test for rolling window, see GH 34605
1 parent bbb89ca commit 8899204

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/window/test_rolling.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,3 +663,21 @@ def test_iter_rolling_datetime(expected, expected_index, window):
663663

664664
for (expected, actual) in zip(expected, ser.rolling(window)):
665665
tm.assert_series_equal(actual, expected)
666+
667+
668+
@pytest.mark.parametrize("groupings", [([{"level": 0}, {"by": "X"}])])
669+
def test_rolling_positional_argument(groupings):
670+
# GH 34605
671+
672+
def scaled_sum(*args):
673+
if len(args) < 2:
674+
raise ValueError("The function needs two arguments")
675+
array, scale = args
676+
return array.sum() / scale
677+
678+
df = DataFrame(data={"X": range(5)}, index=[0, 0, 1, 1, 1])
679+
680+
df.rolling(1).apply(scaled_sum, raw=True, args=(2,))
681+
682+
for grouping in groupings:
683+
df.groupby(**grouping).rolling(1).apply(scaled_sum, raw=True, args=(2,))

0 commit comments

Comments
 (0)