Skip to content

TST: GH34037 add test for type error when using parameter 'min_period' #42940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 17, 2021

Conversation

horaceklai
Copy link
Contributor

@horaceklai horaceklai commented Aug 8, 2021

@@ -2407,3 +2407,19 @@ def test_datetime_categorical_multikey_groupby_indices():
("c", Timestamp("2018-03-01 00:00:00")): np.array([2]),
}
assert result == expected


def test_rolling_min_period():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to mention in this function title that min_period is incorrect

test_df.columns = ["name", "val"]

# correct one
test_df.groupby("name")["val"].rolling(window=2, min_periods=1).sum()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to test this line

# GH34037
result_error_msg = r"__init__\(\) got an unexpected keyword argument 'min_period'"
with pytest.raises(TypeError, match=result_error_msg):
name_l = ["Alice"] * 5 + ["Bob"] * 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the setup code should ideally be before the pytest.raises call

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite Window rolling, ewma, expanding labels Aug 8, 2021
@mroeschke mroeschke added this to the 1.4 milestone Aug 8, 2021
@mroeschke mroeschke merged commit bc16631 into pandas-dev:master Aug 17, 2021
@mroeschke
Copy link
Member

Thanks @horaceklai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: "min_period" and "min_periods" problem in df.groupby().rolling
2 participants