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

Method test_groupby_rolling

pandas/tests/window/test_groupby.py:269–282  ·  pandas/tests/window/test_groupby.py::TestRolling.test_groupby_rolling
(self, expected_value, raw_value)

Source from the content-addressed store, hash-verified

267
268 @pytest.mark.parametrize(class="st">"expected_value,raw_value", [[1.0, True], [0.0, False]])
269 def test_groupby_rolling(self, expected_value, raw_value):
270 class="cm"># GH 31754
271
272 def isnumpyarray(x):
273 return int(isinstance(x, np.ndarray))
274
275 df = DataFrame({class="st">"id": [1, 1, 1], class="st">"value": [1, 2, 3]})
276 result = df.groupby(class="st">"id").value.rolling(1).apply(isnumpyarray, raw=raw_value)
277 expected = Series(
278 [expected_value] * 3,
279 index=MultiIndex.from_tuples(((1, 0), (1, 1), (1, 2)), names=[class="st">"id", None]),
280 name=class="st">"value",
281 )
282 tm.assert_series_equal(result, expected)
283
284 def test_groupby_rolling_center_center(self):
285 class="cm"># GH 35552

Callers

nothing calls this directly

Calls 6

groupbyMethod · 0.95
DataFrameClass · 0.90
SeriesClass · 0.90
applyMethod · 0.45
rollingMethod · 0.45
from_tuplesMethod · 0.45

Tested by

no test coverage detected