diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 8208abc23551d..d0fed21b15897 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -832,3 +832,32 @@ def test_concat_mismatched_keys_length(): concat((x for x in sers), keys=(y for y in keys), axis=1) with tm.assert_produces_warning(FutureWarning, match=msg): concat((x for x in sers), keys=(y for y in keys), axis=0) + + +def test_concat_multiindex_with_category(): + df1 = DataFrame( + { + "c1": Series(list("abc"), dtype="category"), + "c2": Series(list("eee"), dtype="category"), + "i2": Series([1, 2, 3]), + } + ) + df1 = df1.set_index(["c1", "c2"]) + df2 = DataFrame( + { + "c1": Series(list("abc"), dtype="category"), + "c2": Series(list("eee"), dtype="category"), + "i2": Series([4, 5, 6]), + } + ) + df2 = df2.set_index(["c1", "c2"]) + result = concat([df1, df2]) + expected = DataFrame( + { + "c1": Series(list("abcabc"), dtype="category"), + "c2": Series(list("eeeeee"), dtype="category"), + "i2": Series([1, 2, 3, 4, 5, 6]), + } + ) + expected = expected.set_index(["c1", "c2"]) + tm.assert_frame_equal(result, expected)