@@ -112,22 +112,22 @@ def cmp_method(self, other):
112
112
if other .ndim > 0 and len (self ) != len (other ):
113
113
raise ValueError ("Lengths must match to compare" )
114
114
115
- if is_object_dtype (self ) and isinstance (other , ABCCategorical ):
115
+ if is_object_dtype (self . dtype ) and isinstance (other , ABCCategorical ):
116
116
left = type (other )(self ._values , dtype = other .dtype )
117
117
return op (left , other )
118
- elif is_object_dtype (self ) and isinstance (other , ExtensionArray ):
118
+ elif is_object_dtype (self . dtype ) and isinstance (other , ExtensionArray ):
119
119
# e.g. PeriodArray
120
120
with np .errstate (all = "ignore" ):
121
- result = op (self .values , other )
121
+ result = op (self ._values , other )
122
122
123
- elif is_object_dtype (self ) and not isinstance (self , ABCMultiIndex ):
123
+ elif is_object_dtype (self . dtype ) and not isinstance (self , ABCMultiIndex ):
124
124
# don't pass MultiIndex
125
125
with np .errstate (all = "ignore" ):
126
- result = ops .comp_method_OBJECT_ARRAY (op , self .values , other )
126
+ result = ops .comp_method_OBJECT_ARRAY (op , self ._values , other )
127
127
128
128
else :
129
129
with np .errstate (all = "ignore" ):
130
- result = op (self .values , np .asarray (other ))
130
+ result = op (self ._values , np .asarray (other ))
131
131
132
132
if is_bool_dtype (result ):
133
133
return result
@@ -510,7 +510,7 @@ def _shallow_copy(self, values=None, name: Label = no_default):
510
510
name = self .name if name is no_default else name
511
511
cache = self ._cache .copy () if values is None else {}
512
512
if values is None :
513
- values = self .values
513
+ values = self ._values
514
514
515
515
result = self ._simple_new (values , name = name )
516
516
result ._cache = cache
@@ -722,7 +722,7 @@ def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs):
722
722
indices = ensure_platform_int (indices )
723
723
if self ._can_hold_na :
724
724
taken = self ._assert_take_fillable (
725
- self .values ,
725
+ self ._values ,
726
726
indices ,
727
727
allow_fill = allow_fill ,
728
728
fill_value = fill_value ,
@@ -734,7 +734,7 @@ def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs):
734
734
raise ValueError (
735
735
f"Unable to fill values because { cls_name } cannot contain NA"
736
736
)
737
- taken = self .values .take (indices )
737
+ taken = self ._values .take (indices )
738
738
return self ._shallow_copy (taken )
739
739
740
740
def _assert_take_fillable (
@@ -1988,7 +1988,7 @@ def is_all_dates(self) -> bool:
1988
1988
"""
1989
1989
Whether or not the index values only consist of dates.
1990
1990
"""
1991
- return is_datetime_array (ensure_object (self .values ))
1991
+ return is_datetime_array (ensure_object (self ._values ))
1992
1992
1993
1993
# --------------------------------------------------------------------
1994
1994
# Pickle Methods
@@ -2339,13 +2339,13 @@ def _get_unique_index(self, dropna: bool = False):
2339
2339
if self .is_unique and not dropna :
2340
2340
return self
2341
2341
2342
- values = self .values
2343
-
2344
2342
if not self .is_unique :
2345
2343
values = self .unique ()
2346
2344
if not isinstance (self , ABCMultiIndex ):
2347
2345
# extract an array to pass to _shallow_copy
2348
2346
values = values ._data
2347
+ else :
2348
+ values = self ._values
2349
2349
2350
2350
if dropna :
2351
2351
try :
0 commit comments