Skip to content

Commit b4aa48f

Browse files
authored
TST: Test reindex w/ multiindex df (GH21247) (pandas-dev#42528)
1 parent 6bcb37e commit b4aa48f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pandas/tests/indexes/multi/test_reindex.py

+28
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,31 @@ def test_reindex_not_all_tuples():
133133
tm.assert_index_equal(res, idx)
134134
expected = np.array([0, 1, 2, -1], dtype=np.intp)
135135
tm.assert_numpy_array_equal(indexer, expected)
136+
137+
138+
def test_reindex_limit_arg_with_multiindex():
139+
# GH21247
140+
141+
idx = MultiIndex.from_tuples([(3, "A"), (4, "A"), (4, "B")])
142+
143+
df = pd.Series([0.02, 0.01, 0.012], index=idx)
144+
145+
new_idx = MultiIndex.from_tuples(
146+
[
147+
(3, "A"),
148+
(3, "B"),
149+
(4, "A"),
150+
(4, "B"),
151+
(4, "C"),
152+
(5, "B"),
153+
(5, "C"),
154+
(6, "B"),
155+
(6, "C"),
156+
]
157+
)
158+
159+
with pytest.raises(
160+
ValueError,
161+
match="limit argument only valid if doing pad, backfill or nearest reindexing",
162+
):
163+
df.reindex(new_idx, fill_value=0, limit=1)

0 commit comments

Comments
 (0)