Skip to content

Commit c3c4ccf

Browse files
authored
CLN: .values -> ._values (#34083)
1 parent 5691f4e commit c3c4ccf

File tree

11 files changed

+20
-19
lines changed

11 files changed

+20
-19
lines changed

pandas/core/arrays/interval.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from pandas.core.dtypes.dtypes import IntervalDtype
2828
from pandas.core.dtypes.generic import (
2929
ABCDatetimeIndex,
30-
ABCExtensionArray,
3130
ABCIndexClass,
3231
ABCIntervalIndex,
3332
ABCPeriodIndex,
@@ -767,7 +766,7 @@ def size(self) -> int:
767766
# Avoid materializing self.values
768767
return self.left.size
769768

770-
def shift(self, periods: int = 1, fill_value: object = None) -> ABCExtensionArray:
769+
def shift(self, periods: int = 1, fill_value: object = None) -> "IntervalArray":
771770
if not len(self) or periods == 0:
772771
return self.copy()
773772

pandas/core/dtypes/cast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def is_nested_object(obj) -> bool:
103103
This may not be necessarily be performant.
104104
105105
"""
106-
if isinstance(obj, ABCSeries) and is_object_dtype(obj):
106+
if isinstance(obj, ABCSeries) and is_object_dtype(obj.dtype):
107107

108-
if any(isinstance(v, ABCSeries) for v in obj.values):
108+
if any(isinstance(v, ABCSeries) for v in obj._values):
109109
return True
110110

111111
return False

pandas/core/frame.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ def dot(self, other):
11601160
left = self.reindex(columns=common, copy=False)
11611161
right = other.reindex(index=common, copy=False)
11621162
lvals = left.values
1163-
rvals = right.values
1163+
rvals = right._values
11641164
else:
11651165
left = self
11661166
lvals = self.values
@@ -1892,7 +1892,7 @@ def to_records(
18921892
if index:
18931893
if isinstance(self.index, MultiIndex):
18941894
# array of tuples to numpy cols. copy copy copy
1895-
ix_vals = list(map(np.array, zip(*self.index.values)))
1895+
ix_vals = list(map(np.array, zip(*self.index._values)))
18961896
else:
18971897
ix_vals = [self.index.values]
18981898

@@ -3010,7 +3010,7 @@ def _setitem_frame(self, key, value):
30103010
raise ValueError("Array conditional must be same shape as self")
30113011
key = self._constructor(key, **self._construct_axes_dict())
30123012

3013-
if key.values.size and not is_bool_dtype(key.values):
3013+
if key.size and not is_bool_dtype(key.values):
30143014
raise TypeError(
30153015
"Must pass DataFrame or 2-d ndarray with boolean values only"
30163016
)
@@ -7452,7 +7452,7 @@ def applymap(self, func) -> "DataFrame":
74527452
def infer(x):
74537453
if x.empty:
74547454
return lib.map_infer(x, func)
7455-
return lib.map_infer(x.astype(object).values, func)
7455+
return lib.map_infer(x.astype(object)._values, func)
74567456

74577457
return self.apply(infer)
74587458

pandas/core/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4983,7 +4983,7 @@ def sample(
49834983
else:
49844984
raise ValueError("Invalid weights: weights sum to zero")
49854985

4986-
weights = weights.values
4986+
weights = weights._values
49874987

49884988
# If no frac or n, default to n=1.
49894989
if n is None and frac is None:

pandas/core/groupby/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ def nth(self, n: Union[int, List[int]], dropna: Optional[str] = None) -> DataFra
19701970

19711971
grb = dropped.groupby(grouper, as_index=self.as_index, sort=self.sort)
19721972
sizes, result = grb.size(), grb.nth(n)
1973-
mask = (sizes < max_len).values
1973+
mask = (sizes < max_len)._values
19741974

19751975
# set the results which don't meet the criteria
19761976
if len(result) and mask.any():

pandas/core/indexes/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,15 @@ def astype(self, dtype, copy=True):
639639
elif is_categorical_dtype(dtype):
640640
from pandas.core.indexes.category import CategoricalIndex
641641

642-
return CategoricalIndex(self.values, name=self.name, dtype=dtype, copy=copy)
642+
return CategoricalIndex(
643+
self._values, name=self.name, dtype=dtype, copy=copy
644+
)
643645

644646
elif is_extension_array_dtype(dtype):
645647
return Index(np.asarray(self), name=self.name, dtype=dtype, copy=copy)
646648

647649
try:
648-
casted = self.values.astype(dtype, copy=copy)
650+
casted = self._values.astype(dtype, copy=copy)
649651
except (TypeError, ValueError) as err:
650652
raise TypeError(
651653
f"Cannot cast {type(self).__name__} to dtype {dtype}"
@@ -906,7 +908,7 @@ def format(self, name: bool = False, formatter=None, **kwargs):
906908
return self._format_with_header(header, **kwargs)
907909

908910
def _format_with_header(self, header, na_rep="NaN", **kwargs):
909-
values = self.values
911+
values = self._values
910912

911913
from pandas.io.formats.format import format_array
912914

pandas/core/indexes/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def to_series(self, keep_tz=lib.no_default, index=None, name=None):
440440
# preserve the tz & copy
441441
values = self.copy(deep=True)
442442
else:
443-
values = self.values.copy()
443+
values = self._values.view("M8[ns]").copy()
444444

445445
return Series(values, index=index, name=name)
446446

pandas/core/indexes/multi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ def is_monotonic_increasing(self) -> bool:
14641464

14651465
# reversed() because lexsort() wants the most significant key last.
14661466
values = [
1467-
self._get_level_values(i).values for i in reversed(range(len(self.levels)))
1467+
self._get_level_values(i)._values for i in reversed(range(len(self.levels)))
14681468
]
14691469
try:
14701470
sort_order = np.lexsort(values)
@@ -2455,7 +2455,7 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):
24552455
"tolerance not implemented yet for MultiIndex"
24562456
)
24572457
indexer = self._engine.get_indexer(
2458-
values=self.values, target=target, method=method, limit=limit
2458+
values=self._values, target=target, method=method, limit=limit
24592459
)
24602460
elif method == "nearest":
24612461
raise NotImplementedError(

pandas/core/internals/construction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def _homogenize(data, index, dtype: Optional[DtypeObj]):
347347
val = com.dict_compat(val)
348348
else:
349349
val = dict(val)
350-
val = lib.fast_multiget(val, oindex.values, default=np.nan)
350+
val = lib.fast_multiget(val, oindex._values, default=np.nan)
351351
val = sanitize_array(
352352
val, index, dtype=dtype, copy=False, raise_cast_failure=False
353353
)

pandas/core/internals/managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def get_axe(block, qs, axes):
475475
b.mgr_locs = sb.mgr_locs
476476

477477
else:
478-
new_axes[axis] = Index(np.concatenate([ax.values for ax in axes]))
478+
new_axes[axis] = Index(np.concatenate([ax._values for ax in axes]))
479479

480480
if transposed:
481481
new_axes = new_axes[::-1]

pandas/plotting/_matplotlib/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def _iter_data(self, data=None, keep_index=False, fillna=None):
247247
yield col, values.values
248248

249249
@property
250-
def nseries(self):
250+
def nseries(self) -> int:
251251
if self.data.ndim == 1:
252252
return 1
253253
else:

0 commit comments

Comments
 (0)