Skip to content

Commit fa26bce

Browse files
authored
values->_values (#32662)
1 parent ea9942b commit fa26bce

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

pandas/core/indexes/category.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def _engine(self):
396396
def unique(self, level=None):
397397
if level is not None:
398398
self._validate_index_level(level)
399-
result = self.values.unique()
399+
result = self._values.unique()
400400
# Use _simple_new instead of _shallow_copy to ensure we keep dtype
401401
# of result, not self.
402402
return type(self)._simple_new(result, name=self.name)
@@ -423,7 +423,7 @@ def where(self, cond, other=None):
423423
# 3. Rebuild CategoricalIndex.
424424
if other is None:
425425
other = self._na_value
426-
values = np.where(cond, self.values, other)
426+
values = np.where(cond, self._values, other)
427427
cat = Categorical(values, dtype=self.dtype)
428428
return type(self)._simple_new(cat, name=self.name)
429429

@@ -532,13 +532,13 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):
532532
"method='nearest' not implemented yet for CategoricalIndex"
533533
)
534534

535-
if isinstance(target, CategoricalIndex) and self.values.is_dtype_equal(target):
536-
if self.values.equals(target.values):
535+
if isinstance(target, CategoricalIndex) and self._values.is_dtype_equal(target):
536+
if self._values.equals(target._values):
537537
# we have the same codes
538538
codes = target.codes
539539
else:
540540
codes = _recode_for_categories(
541-
target.codes, target.categories, self.values.categories
541+
target.codes, target.categories, self._values.categories
542542
)
543543
else:
544544
if isinstance(target, CategoricalIndex):
@@ -560,7 +560,7 @@ def get_indexer_non_unique(self, target):
560560
target = target.codes
561561
indexer, missing = self._engine.get_indexer_non_unique(target)
562562
return ensure_platform_int(indexer), missing
563-
target = target.values
563+
target = target._values
564564

565565
codes = self.categories.get_indexer(target)
566566
indexer, missing = self._engine.get_indexer_non_unique(codes)
@@ -679,7 +679,7 @@ def map(self, mapper):
679679
>>> idx.map({'a': 'first', 'b': 'second'})
680680
Index(['first', 'second', nan], dtype='object')
681681
"""
682-
return self._shallow_copy_with_infer(self.values.map(mapper))
682+
return self._shallow_copy_with_infer(self._values.map(mapper))
683683

684684
def delete(self, loc):
685685
"""

pandas/core/indexes/interval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def __reduce__(self):
409409
@Appender(Index.astype.__doc__)
410410
def astype(self, dtype, copy=True):
411411
with rewrite_exception("IntervalArray", type(self).__name__):
412-
new_values = self.values.astype(dtype, copy=copy)
412+
new_values = self._values.astype(dtype, copy=copy)
413413
if is_interval_dtype(new_values):
414414
return self._shallow_copy(new_values)
415415
return Index.astype(self, dtype, copy=copy)
@@ -887,7 +887,7 @@ def _convert_slice_indexer(self, key: slice, kind: str):
887887
def where(self, cond, other=None):
888888
if other is None:
889889
other = self._na_value
890-
values = np.where(cond, self.values, other)
890+
values = np.where(cond, self._values, other)
891891
result = IntervalArray(values)
892892
return self._shallow_copy(result)
893893

pandas/core/indexes/numeric.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def inferred_type(self) -> str:
248248
@property
249249
def asi8(self) -> np.ndarray:
250250
# do not cache or you'll create a memory leak
251-
return self.values.view(self._default_dtype)
251+
return self._values.view(self._default_dtype)
252252

253253

254254
class Int64Index(IntegerIndex):
@@ -368,7 +368,7 @@ def astype(self, dtype, copy=True):
368368
elif is_integer_dtype(dtype) and not is_extension_array_dtype(dtype):
369369
# TODO(jreback); this can change once we have an EA Index type
370370
# GH 13149
371-
arr = astype_nansafe(self.values, dtype=dtype)
371+
arr = astype_nansafe(self._values, dtype=dtype)
372372
return Int64Index(arr)
373373
return super().astype(dtype, copy=copy)
374374

@@ -395,7 +395,7 @@ def _format_native_types(
395395
from pandas.io.formats.format import FloatArrayFormatter
396396

397397
formatter = FloatArrayFormatter(
398-
self.values,
398+
self._values,
399399
na_rep=na_rep,
400400
float_format=float_format,
401401
decimal=decimal,

0 commit comments

Comments
 (0)