Skip to content

TST: Add test for groupby rename categories with multiIndexes #51555

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

Closed
wants to merge 2 commits into from

Conversation

luke396
Copy link
Contributor

@luke396 luke396 commented Feb 22, 2023

@pytest.mark.parametrize("op", ["add", "sub", "mul", "div"])
def test_groupyby_rename_categories_operation_with_multiindex(op):
# 51500
data = DataFrame(
Copy link
Member

Choose a reason for hiding this comment

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

This is too complicated. First step is to figure out what changed and fixed the bug. Afterwards, we want a dedicated test for this operation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to admit that finding bugs that have been fixed is difficult.

However, I searched the entire test folder and there doesn't seem to be a test written for groupyby along with rename_categories. I would like to add some simpler test cases to test that the behavior between their two methods is as expected. @phofl any suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that testing this is necessary. If rename_categories provides a value Categorical, this should work as expected. I'd suggest going back to a version where the test was failing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BUG: groupby with CategoricalIndex doesn't include unobserved categories by rhshadrach · Pull Request #49373 · pandas-dev/pandas fix the bug.

After comparing the buggy version and the main branch, I noticed that the results from the groupby may differ between the two versions, which in turn led to a series of subsequent issues.

In my opinion, this pull request can be closed because the test cases added to fix the previous bug appear to be complete.

@simonjayhawkins simonjayhawkins added the Testing pandas testing functions or related to the test suite label Feb 22, 2023
@luke396 luke396 closed this Mar 8, 2023
@luke396
Copy link
Contributor Author

luke396 commented Mar 8, 2023

@phofl , I turned it off based on my own judgment, but we can easily turn it back on if necessary.

Edit: I believe that we should also close #51500 since we have already obtained the desired test results previously

@luke396 luke396 deleted the operation-with-multipleindex branch March 8, 2023 00:41
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Unexpected behavior math operations using multiindexes
3 participants