Skip to content

TST: Add a test for multiindex df with na value and adding a new row #53010

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 3 commits into from
May 3, 2023

Conversation

shteken
Copy link
Contributor

@shteken shteken commented Apr 30, 2023

@shteken shteken changed the title add test_multiindex_with_na TST: Add a test for multiindex df with na value and adding a new row Apr 30, 2023
@shteken
Copy link
Contributor Author

shteken commented Apr 30, 2023

Hi,
I am not sure why Minimum Versions check fails. Any hint?
Edit: I just updated my branch and it resolved the issue

Comment on lines 301 to 302
)
df.set_index(["pivot_0", "pivot_1"], inplace=True)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
)
df.set_index(["pivot_0", "pivot_1"], inplace=True)
).set_index(["pivot_0", "pivot_1"])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

May I ask what benefit do we gain from chaining the operations?

Copy link
Member

Choose a reason for hiding this comment

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

We want to avoid inplace=True where possible


df.at[("A", "F"), "col_2"] = 0.0

assert df.loc[("A", "F")]["col_2"] == 0.0
Copy link
Member

Choose a reason for hiding this comment

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

Instead of these asserts, could you construct expected = DataFrame(...) and then use tm.assert_frame_equal(df, expected)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I understand that with your suggestion it would be easier to understand the expected output.

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label May 1, 2023
@mroeschke mroeschke added this to the 2.1 milestone May 3, 2023
@mroeschke mroeschke merged commit 3888179 into pandas-dev:main May 3, 2023
@mroeschke
Copy link
Member

Thanks @shteken

topper-123 pushed a commit to topper-123/pandas that referenced this pull request May 7, 2023
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
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.

MultiIndex Bug Copying Values Incorrectly When Adding Values To Index
2 participants