Skip to content

Commit 1e4e2f4

Browse files
committed
BUG: Fix PyArrow array access in Categorical constructor for Index objects (#60563)
1 parent 6bcd303 commit 1e4e2f4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/core/arrays/categorical.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,12 @@ def __init__(
447447
if isinstance(values.dtype, ArrowDtype) and issubclass(
448448
values.dtype.type, CategoricalDtypeType
449449
):
450-
arr = values._pa_array.combine_chunks()
450+
from pandas import Index
451+
452+
if isinstance(values, Index):
453+
arr = values._data._pa_array.combine_chunks()
454+
else:
455+
arr = values._pa_array.combine_chunks()
451456
categories = arr.dictionary.to_pandas(types_mapper=ArrowDtype)
452457
codes = arr.indices.to_numpy()
453458
dtype = CategoricalDtype(categories, values.dtype.pyarrow_dtype.ordered)

0 commit comments

Comments
 (0)