Skip to content

Commit 42395cb

Browse files
committed
Use __array__ instead of to_list, set dtype in Series
1 parent e689153 commit 42395cb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pandas/core/indexes/accessors.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,10 @@ def __new__(cls, data):
322322
orig = data if is_categorical_dtype(data) else None
323323
if orig is not None:
324324
data = Series(
325-
orig.values.astype(orig.values.categories.dtype),
325+
orig.values.__array__(),
326326
name=orig.name,
327327
copy=False,
328+
dtype=orig.values.categories.dtype,
328329
)
329330

330331
if is_datetime64_dtype(data.dtype):

0 commit comments

Comments
 (0)