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

Method test_groupby_rolling_var

pandas/tests/window/test_groupby.py:835–849  ·  view source on GitHub ↗
(self, window, min_periods, closed, expected)

Source from the content-addressed store, hash-verified

833 ],
834 )
835 def test_groupby_rolling_var(self, window, min_periods, closed, expected):
836 df = DataFrame([1, 2, 3, 4, 5, 6, 7, 8])
837 result = (
838 df.groupby([1, 2, 1, 2, 1, 2, 1, 2])
839 .rolling(window=window, min_periods=min_periods, closed=closed)
840 .var(0)
841 )
842 expected_result = DataFrame(
843 np.array(expected, dtype="float64"),
844 index=MultiIndex(
845 levels=[np.array([1, 2]), [0, 1, 2, 3, 4, 5, 6, 7]],
846 codes=[[0, 0, 0, 0, 1, 1, 1, 1], [0, 2, 4, 6, 1, 3, 5, 7]],
847 ),
848 )
849 tm.assert_frame_equal(result, expected_result)
850
851 @pytest.mark.parametrize(
852 "columns", [MultiIndex.from_tuples([("A", ""), ("B", "C")]), ["A", "B"]]

Callers

nothing calls this directly

Calls 6

groupbyMethod · 0.95
DataFrameClass · 0.90
MultiIndexClass · 0.90
varMethod · 0.45
rollingMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected