-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Add test for filling new rows through reindexing MultiIndex #37726
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
457d388
659d879
5efda6c
00ad9d2
d94a0eb
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 |
---|---|---|
|
@@ -101,3 +101,13 @@ def test_reindex_non_unique(): | |
msg = "cannot handle a non-unique multi-index!" | ||
with pytest.raises(ValueError, match=msg): | ||
a.reindex(new_idx) | ||
|
||
|
||
def test_reindex_fill_added_rows(): | ||
# GH: 23693 | ||
i = pd.MultiIndex.from_tuples([("a", "b"), ("d", "e")]) | ||
df = pd.DataFrame([[0, 7], [3, 4]], index=i, columns=["x", "y"]) | ||
i2 = pd.MultiIndex.from_tuples([("a", "b"), ("d", "e"), ("h", "i")]) | ||
result = df.reindex(i2, axis=0, method="ffill") | ||
expected = pd.DataFrame([[0, 7], [3, 4], [3, 4]], index=i2, columns=["x", "y"]) | ||
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. if the method being tested is DataFrame.reindex, then this belongs in tests.frame.method.test_reindex 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. Sorry, was checking frame/indexing and could not find a reindex file. Moved the test now to the methods folder |
||
tm.assert_frame_equal(result, expected) |
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 use MultiIndex with out the "pd"
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.
and pls avoid 1-letter variable names.
mi
is a good choice for MultiIndex objThere 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.
Done