Skip to content

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

Merged
merged 7 commits into from
Nov 29, 2021
Merged

Conversation

gabrieldi95
Copy link
Contributor

@debnathshoham debnathshoham added the Testing pandas testing functions or related to the test suite label Oct 19, 2021
@jreback jreback added this to the 1.4 milestone Oct 21, 2021
def test_broadcast_multiindex():
# GH34388
df1 = DataFrame({"A": [0, 1, 2], "B": [1, 2, 3]})
df1.columns.set_names("L1", inplace=True)
Copy link
Contributor

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)
Copy link
Contributor

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

@jreback
Copy link
Contributor

jreback commented Nov 14, 2021

can you merge master and update to comments

@gabrieldi95
Copy link
Contributor Author

Yes, I was working on other stuff, will work on it now!



@pytest.mark.parametrize("level", [0, None])
def test_broadcast_multiindex(level):
Copy link
Contributor

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?

Copy link
Member

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

@jreback jreback added MultiIndex Numeric Operations Arithmetic, Comparison, and Logical operations labels Nov 17, 2021
@jreback
Copy link
Contributor

jreback commented Nov 28, 2021

@gabrieldi95 can you merge once again and ping on green

@jreback jreback merged commit f711e71 into pandas-dev:master Nov 29, 2021
@jreback
Copy link
Contributor

jreback commented Nov 29, 2021

thanks @gabrieldi95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiIndex Numeric Operations Arithmetic, Comparison, and Logical operations Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pd.DataFrame.add() does not broadcast across levels, when level is None
4 participants