Skip to content

Commit e47f2ca

Browse files
committed
TST: add tests
1 parent 4e1cd48 commit e47f2ca

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pandas/tests/indexing/test_categorical.py

+26
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,32 @@ 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):
654+
# GH 24206
655+
656+
index = pd.MultiIndex(
657+
[pd.CategoricalIndex(["A", "B"]), pd.CategoricalIndex(["a", "b"])],
658+
[[0, 0, -1, 1], [0, 1, 0, 1]],
659+
)
660+
data = {"col": range(len(index))}
661+
df = DataFrame(data=data, index=index)
662+
663+
res = df.reset_index()
664+
665+
expected = pd.DataFrame(
666+
{
667+
"level_0": pd.Categorical.from_codes(
668+
[0, 0, 1, 1], categories=["A", "B"]
669+
),
670+
"level_1": pd.Categorical.from_codes(
671+
[0, 1, 0, 1], categories=["a", "b"]
672+
),
673+
"col": range(4),
674+
}
675+
)
676+
677+
tm.assert_frame_equal(res, expected)
678+
653679
def test_loc_and_at_with_categorical_index(self):
654680
# GH 20629
655681
s = Series([1, 2, 3], index=pd.CategoricalIndex(["A", "B", "C"]))

0 commit comments

Comments
 (0)