Skip to content

Commit 98ca0d9

Browse files
committed
TST: GH34037 add test for type error when using parameter 'min_period'
1 parent 3d135f3 commit 98ca0d9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/groupby/test_groupby.py

+16
Original file line numberDiff line numberDiff line change
@@ -2407,3 +2407,19 @@ def test_datetime_categorical_multikey_groupby_indices():
24072407
("c", Timestamp("2018-03-01 00:00:00")): np.array([2]),
24082408
}
24092409
assert result == expected
2410+
2411+
2412+
def test_rolling_min_period():
2413+
# GH34037
2414+
result_error_msg = r"__init__\(\) got an unexpected keyword argument 'min_period'"
2415+
with pytest.raises(TypeError, match=result_error_msg):
2416+
name_l = ["Alice"] * 5 + ["Bob"] * 5
2417+
val_l = [np.nan, np.nan, 1, 2, 3] + [np.nan, 1, 2, 3, 4]
2418+
test_df = DataFrame([name_l, val_l]).T
2419+
test_df.columns = ["name", "val"]
2420+
2421+
# correct one
2422+
test_df.groupby("name")["val"].rolling(window=2, min_periods=1).sum()
2423+
2424+
# wrong one with "min_period” parameter
2425+
test_df.groupby("name")["val"].rolling(window=2, min_period=1).sum()

0 commit comments

Comments
 (0)