-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
TST: added test for groupby when calling first, last, nth (GH29645) #43358
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
Changes from 2 commits
8379f11
384d32f
a9646d8
2636ad7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2419,3 +2419,22 @@ def test_rolling_wrong_param_min_period(): | |
| result_error_msg = r"__init__\(\) got an unexpected keyword argument 'min_period'" | ||
| with pytest.raises(TypeError, match=result_error_msg): | ||
| test_df.groupby("name")["val"].rolling(window=2, min_period=1).sum() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("method", ["first", "last", "nth"]) | ||
| @pytest.mark.parametrize("nans", [None, np.nan]) | ||
| def test_groupby_last_first_nth_with_none(method, nans): | ||
| # GH29645 | ||
| expected = Series([True]) | ||
| data = ( | ||
| Series([nans, "x", nans, "y", nans], index=[0, 0, 0, 0, 0]) | ||
| .isna() | ||
|
||
| .groupby(level=0) | ||
| ) | ||
|
|
||
| if method == "nth": | ||
| result = getattr(data, method)(2) | ||
| else: | ||
| result = getattr(data, method)() | ||
|
|
||
| tm.assert_series_equal(result, expected) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move to test_nth.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing