We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4e1cd48 commit e47f2caCopy full SHA for e47f2ca
pandas/tests/indexing/test_categorical.py
@@ -650,6 +650,32 @@ def test_loc_slice(self):
650
expected = self.df.iloc[[2, 3, 4]]
651
tm.assert_frame_equal(result, expected)
652
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
679
def test_loc_and_at_with_categorical_index(self):
680
# GH 20629
681
s = Series([1, 2, 3], index=pd.CategoricalIndex(["A", "B", "C"]))
0 commit comments