-
-
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
Conversation
|
||
def test_reindex_fill_added_rows(): | ||
# GH: 23693 | ||
i = pd.MultiIndex.from_tuples([("a", "b"), ("d", "e")]) |
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 obj
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.
Done
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 comment
The 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 comment
The 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
@@ -864,3 +864,12 @@ def test_reindex_signature(self): | |||
"fill_value", | |||
"tolerance", | |||
} | |||
|
|||
def test_reindex_fill_added_rows(self): |
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 add "multiindex" in the name somehow, and "fill" -> "ffill"
half-sentence after the GH ref below on what the original problem was?
and total nitpick exclusively if you want to do me a kindness: I like the pattern # GH#23693
for the GH references
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.
All done :)
thanks @phofl |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Issue was fixed previously