Skip to content

Commit 4d6e5e7

Browse files
author
adrien pacifico
committed
BUG: Fix #51362 special handling for categorical arrays in concat_compat
1 parent 437a322 commit 4d6e5e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pandas/core/dtypes/concat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def concat_compat(
6969
-------
7070
a single array, preserving the combined dtypes
7171
"""
72+
# Special handling for categorical arrays solves #51362
73+
if (len(to_concat) and
74+
all(isinstance(arr.dtype, CategoricalDtype) for arr in to_concat) and
75+
axis == 0):
76+
return union_categoricals(to_concat)
7277
if len(to_concat) and lib.dtypes_all_equal([obj.dtype for obj in to_concat]):
7378
# fastpath!
7479
obj = to_concat[0]

0 commit comments

Comments
 (0)