-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
testing broadcast on multiindex #44094
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
Conversation
gabrieldi95
commented
Oct 19, 2021
- closes BUG: pd.DataFrame.add() does not broadcast across levels, when level is None #34388
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
def test_broadcast_multiindex(): | ||
# GH34388 | ||
df1 = DataFrame({"A": [0, 1, 2], "B": [1, 2, 3]}) | ||
df1.columns.set_names("L1", inplace=True) |
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.
don't use inplace in tests, unless its actually testing inplace.
df2 = DataFrame({("A", "C"): [0, 0, 0], ("A", "D"): [0, 0, 0]}) | ||
df2.columns.set_names(["L1", "L2"], inplace=True) | ||
|
||
result = df1.add(df2) |
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.
parameterize this over level=0
and level=None
can you merge master and update to comments |
Yes, I was working on other stuff, will work on it now! |
|
||
|
||
@pytest.mark.parametrize("level", [0, None]) | ||
def test_broadcast_multiindex(level): |
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.
@jbrockmendel test in a good location?
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.
id put it in the TestFrameFlexArithmetic class in this file
@gabrieldi95 can you merge once again and ping on green |
thanks @gabrieldi95 |