Skip to content

Commit b097a32

Browse files
committed
feedback: parametrize on both examples from OP
1 parent eb88e43 commit b097a32

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pandas/tests/indexing/test_categorical.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -650,24 +650,22 @@ def test_loc_slice(self):
650650
expected = self.df.iloc[[2, 3, 4]]
651651
tm.assert_frame_equal(result, expected)
652652

653-
def test_reindexing_with_missing_values(self):
653+
@pytest.mark.parametrize(
654+
"codes", ([[0, 0, 1, 1], [0, 1, 0, 1]], [[0, 0, -1, 1], [0, 1, 0, 1]])
655+
)
656+
def test_reindexing_with_missing_values(self, codes):
654657
# GH 24206
655658

656659
index = pd.MultiIndex(
657-
[pd.CategoricalIndex(["A", "B"]), pd.CategoricalIndex(["a", "b"])],
658-
[[0, 0, -1, 1], [0, 1, 0, 1]],
660+
[pd.CategoricalIndex(["A", "B"]), pd.CategoricalIndex(["a", "b"])], codes
659661
)
660662
data = {"col": range(len(index))}
661663
df = DataFrame(data=data, index=index)
662664

663665
expected = pd.DataFrame(
664666
{
665-
"level_0": pd.Categorical.from_codes(
666-
[0, 0, 1, 1], categories=["A", "B"]
667-
),
668-
"level_1": pd.Categorical.from_codes(
669-
[0, 1, 0, 1], categories=["a", "b"]
670-
),
667+
"level_0": pd.Categorical.from_codes(codes[0], categories=["A", "B"]),
668+
"level_1": pd.Categorical.from_codes(codes[1], categories=["a", "b"]),
671669
"col": range(4),
672670
}
673671
)

0 commit comments

Comments
 (0)