MCPcopy
hub / github.com/pandas-dev/pandas / test_rolling_positional_argument

Function test_rolling_positional_argument

pandas/tests/window/test_rolling.py:931–947  ·  view source on GitHub ↗
(grouping, _index, raw)

Source from the content-addressed store, hash-verified

929 ],
930)
931def 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])

Callers

nothing calls this directly

Calls 5

dropMethod · 0.95
groupbyMethod · 0.95
DataFrameClass · 0.90
applyMethod · 0.45
rollingMethod · 0.45

Tested by

no test coverage detected