| 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"]] |