Skip to content

Commit baa86a2

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

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/window/test_rolling.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from datetime import datetime, timedelta
23

34
import numpy as np
@@ -663,3 +664,19 @@ def test_iter_rolling_datetime(expected, expected_index, window):
663664

664665
for (expected, actual) in zip(expected, ser.rolling(window)):
665666
tm.assert_series_equal(actual, expected)
667+
668+
669+
@pytest.mark.skipif(sys.version_info < (3, 8), reason="requires positional only args")
670+
@pytest.mark.parametrize("groupings", [([{"level": 0}, {"by": "X"}])])
671+
def test_rolling_positional_argument(groupings):
672+
# GH 34605
673+
674+
def scaled_sum(array, scale, /):
675+
return array.sum() / scale
676+
677+
df = DataFrame(data={"X": range(5)}, index=[0, 0, 1, 1, 1])
678+
679+
df.rolling(1).apply(scaled_sum, raw=True, args=(2,))
680+
681+
for grouping in groupings:
682+
df.groupby(**grouping).rolling(1).apply(scaled_sum, raw=True, args=(2,))

0 commit comments

Comments
 (0)