-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
TST: Add regression test for MultiIndex merge after reset_index #63256
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
TST: Add regression test for MultiIndex merge after reset_index #63256
Conversation
- Add test for GH#62150 - Bug was present in 2.3.1, fixed in 3.0.0 - Test ensures merge works when one df has single-level index and other has multi-level index after reset_index() Closes pandas-dev#62150
| # GH#62150 - merging reset MultiIndex when one df has single-level index | ||
| # Bug existed in 2.3.1, fixed in 3.0.0, this test prevents regression |
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 remove all the comments (and the comments below) except GH#62150?
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
| df = DataFrame(data={("column_1", ""): [1, 1], ("column_2", ""): [2, 2]}) | ||
| df.index = MultiIndex.from_arrays( | ||
| [[1, 1], ["metadata_1", "metadata_2"]], names=["index", "metadata"] | ||
| ) | ||
|
|
||
| # Create second dataframe with single index and MultiIndex columns | ||
| df2 = DataFrame(data=[1, 1], index=[1, 1]).rename_axis("index", axis=0) | ||
| df2.columns = MultiIndex.from_product([["new_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.
As mentioned in #62150 (comment), it would be good to construct these DataFrames directly
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.
Gotcha, I'll do that
|
Thanks @zachyattack23 |
Closes #62150
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.AGENTS.md.