| 929 | ], |
| 930 | ) |
| 931 | def test_rolling_positional_argument(grouping, _index, raw): |
| 932 | # GH 34605 |
| 933 | |
| 934 | def scaled_sum(*args): |
| 935 | if len(args) < 2: |
| 936 | raise ValueError("The function needs two arguments") |
| 937 | array, scale = args |
| 938 | return array.sum() / scale |
| 939 | |
| 940 | df = DataFrame(data={"X": range(5)}, index=[0, 0, 1, 1, 1]) |
| 941 | |
| 942 | expected = DataFrame(data={"X": [0.0, 0.5, 1.0, 1.5, 2.0]}, index=_index) |
| 943 | # GH 40341 |
| 944 | if "by" in grouping: |
| 945 | expected = expected.drop(columns="X", errors="ignore") |
| 946 | result = df.groupby(**grouping).rolling(1).apply(scaled_sum, raw=raw, args=(2,)) |
| 947 | tm.assert_frame_equal(result, expected) |
| 948 | |
| 949 | |
| 950 | @pytest.mark.parametrize("add", [0.0, 2.0]) |