-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Test case dataframe.groupby incorrect with multiindex and None value #45982
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
Test case dataframe.groupby incorrect with multiindex and None value #45982
Conversation
) | ||
grps = df.groupby(by=["A", "B"]) | ||
|
||
with pytest.raises(KeyError): |
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 add a match statement? I think pre-commit is complaining about this too
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.
Please let the reviewer mark conversations as resolved
I mean:
pytest.raises(KeyError, match="String to match"):
) | ||
grps = df.groupby(by=["A", "B"]) | ||
|
||
with pytest.raises(KeyError, match="Selecting group which is not exist"): |
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.
Please run your test locally before pushing, it is failing.
@@ -314,3 +314,18 @@ def test_groupby_duplicated_columns(func): | |||
[[1.5, 3.0, 1.5]], columns=["A", "B", "A"], index=pd.Index(["G"], name="C") | |||
) | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
|
|||
def test_dataframe_groupby_incorrect_with_multiindex_make_df_from_data(): |
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.
Could you give a better name? Something like test_groupby_get_nonexisting_groups
lgtm @phofl merge when ready |
Thanks @weikhor |
…andas-dev#45982) * Add test * Update test_indexing.py * Update test_indexing.py * Update pytest.raises * add match * change function
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.