Skip to content

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

Merged

Conversation

weikhor
Copy link
Contributor

@weikhor weikhor commented Feb 14, 2022

@pep8speaks
Copy link

pep8speaks commented Feb 14, 2022

Hello @weikhor! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-02-15 12:03:06 UTC

@weikhor weikhor changed the title Add test Test case dataframe.groupby incorrect with multiindex and None value Feb 14, 2022
)
grps = df.groupby(by=["A", "B"])

with pytest.raises(KeyError):
Copy link
Member

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

Copy link
Member

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"):
Copy link
Member

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():
Copy link
Member

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

@weikhor weikhor requested a review from phofl February 16, 2022 04:03
@jreback jreback added Groupby MultiIndex Testing pandas testing functions or related to the test suite labels Feb 16, 2022
@jreback jreback added this to the 1.5 milestone Feb 16, 2022
@jreback
Copy link
Contributor

jreback commented Feb 16, 2022

lgtm @phofl merge when ready

@phofl phofl merged commit 6cd6069 into pandas-dev:main Feb 16, 2022
@phofl
Copy link
Member

phofl commented Feb 16, 2022

Thanks @weikhor

yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
…andas-dev#45982)

* Add test

* Update test_indexing.py

* Update test_indexing.py

* Update pytest.raises

* add match

* change function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groupby MultiIndex Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dataframe.groupby incorrect with multiindex and None value
4 participants