Skip to content

TST: Test reindex w/ multiindex df (GH21247) #42528

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 1 commit into from
Jul 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pandas/tests/indexes/multi/test_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,31 @@ def test_reindex_not_all_tuples():
tm.assert_index_equal(res, idx)
expected = np.array([0, 1, 2, -1], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)


def test_reindex_limit_arg_with_multiindex():
# GH21247

idx = MultiIndex.from_tuples([(3, "A"), (4, "A"), (4, "B")])

df = pd.Series([0.02, 0.01, 0.012], index=idx)

new_idx = MultiIndex.from_tuples(
[
(3, "A"),
(3, "B"),
(4, "A"),
(4, "B"),
(4, "C"),
(5, "B"),
(5, "C"),
(6, "B"),
(6, "C"),
]
)

with pytest.raises(
ValueError,
match="limit argument only valid if doing pad, backfill or nearest reindexing",
):
df.reindex(new_idx, fill_value=0, limit=1)