-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,6 +290,22 @@ def test_datetime_object_multiindex(self): | |
|
||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_multiindex_with_na(self): | ||
df = DataFrame( | ||
[ | ||
["A", np.nan, 1.23, 4.56], | ||
["A", "G", 1.23, 4.56], | ||
["A", "D", 9.87, 10.54], | ||
], | ||
columns=["pivot_0", "pivot_1", "col_1", "col_2"], | ||
) | ||
df.set_index(["pivot_0", "pivot_1"], inplace=True) | ||
|
||
df.at[("A", "F"), "col_2"] = 0.0 | ||
|
||
assert df.loc[("A", "F")]["col_2"] == 0.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of these There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
assert pd.isna(df.loc[("A", "F")]["col_1"]) | ||
|
||
|
||
class TestSorted: | ||
"""everything you wanted to test about sorting""" | ||
|
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.
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.
May I ask what benefit do we gain from chaining the operations?
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.
We want to avoid
inplace=True
where possible