@@ -832,3 +832,32 @@ def test_concat_mismatched_keys_length():
832
832
concat ((x for x in sers ), keys = (y for y in keys ), axis = 1 )
833
833
with tm .assert_produces_warning (FutureWarning , match = msg ):
834
834
concat ((x for x in sers ), keys = (y for y in keys ), axis = 0 )
835
+
836
+
837
+ def test_concat_multiindex_with_category ():
838
+ df1 = DataFrame (
839
+ {
840
+ "c1" : Series (list ("abc" ), dtype = "category" ),
841
+ "c2" : Series (list ("eee" ), dtype = "category" ),
842
+ "i2" : Series ([1 , 2 , 3 ]),
843
+ }
844
+ )
845
+ df1 = df1 .set_index (["c1" , "c2" ])
846
+ df2 = DataFrame (
847
+ {
848
+ "c1" : Series (list ("abc" ), dtype = "category" ),
849
+ "c2" : Series (list ("eee" ), dtype = "category" ),
850
+ "i2" : Series ([4 , 5 , 6 ]),
851
+ }
852
+ )
853
+ df2 = df2 .set_index (["c1" , "c2" ])
854
+ result = concat ([df1 , df2 ])
855
+ expected = DataFrame (
856
+ {
857
+ "c1" : Series (list ("abcabc" ), dtype = "category" ),
858
+ "c2" : Series (list ("eeeeee" ), dtype = "category" ),
859
+ "i2" : Series ([1 , 2 , 3 , 4 , 5 , 6 ]),
860
+ }
861
+ )
862
+ expected = expected .set_index (["c1" , "c2" ])
863
+ tm .assert_frame_equal (result , expected )
0 commit comments