Skip to content

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

Merged
merged 5 commits into from
Nov 13, 2020

Conversation

phofl
Copy link
Member

@phofl phofl commented Nov 9, 2020

Issue was fixed previously

@phofl phofl added MultiIndex Needs Tests Unit test(s) needed to prevent regressions Indexing Related to indexing on series/frames, not to indexes themselves labels Nov 9, 2020

def test_reindex_fill_added_rows():
# GH: 23693
i = pd.MultiIndex.from_tuples([("a", "b"), ("d", "e")])
Copy link
Member

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"

Copy link
Member

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

Copy link
Member Author

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"])
Copy link
Member

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

Copy link
Member Author

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):
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

All done :)

@jreback jreback added this to the 1.2 milestone Nov 13, 2020
@jreback jreback merged commit feb29c7 into pandas-dev:master Nov 13, 2020
@jreback
Copy link
Contributor

jreback commented Nov 13, 2020

thanks @phofl

@phofl phofl deleted the 23693 branch November 13, 2020 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame.reindex with specified fill method fails for MultiIndex
3 participants