Skip to content

Commit 1b81162

Browse files
committed
change condition
1 parent 4855994 commit 1b81162

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/core/arrays/categorical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def __init__(
457457
# Check for pandas Series/ Index with object dtye
458458
preserve_object_dtpe = False
459459
if isinstance(values, (ABCSeries, ABCIndex)):
460-
if getattr(values.dtype, "name", None) == "object":
460+
if values.dtype == "object":
461461
preserve_object_dtpe = True
462462
if not isinstance(values, ABCIndex):
463463
# in particular RangeIndex xref test_index_equal_range_categories
@@ -475,7 +475,7 @@ def __init__(
475475
"by passing in a categories argument."
476476
) from err
477477

478-
# If we should prserve object dtype, force categories to object dtype
478+
# If we should preserve object dtype, force categories to object dtype
479479
if preserve_object_dtpe:
480480
# Only preserve object dtype if not all elements are strings
481481
if not all(isinstance(x, str) for x in categories):

0 commit comments

Comments
 (0)