Skip to content

CLN: .values -> ._values #34083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 19, 2020
3 changes: 1 addition & 2 deletions pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from pandas.core.dtypes.dtypes import IntervalDtype
from pandas.core.dtypes.generic import (
ABCDatetimeIndex,
ABCExtensionArray,
ABCIndexClass,
ABCIntervalIndex,
ABCPeriodIndex,
Expand Down Expand Up @@ -767,7 +766,7 @@ def size(self) -> int:
# Avoid materializing self.values
return self.left.size

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

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def is_nested_object(obj) -> bool:
This may not be necessarily be performant.

"""
if isinstance(obj, ABCSeries) and is_object_dtype(obj):
if isinstance(obj, ABCSeries) and is_object_dtype(obj.dtype):

if any(isinstance(v, ABCSeries) for v in obj.values):
if any(isinstance(v, ABCSeries) for v in obj._values):
return True

return False
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ def dot(self, other):
left = self.reindex(columns=common, copy=False)
right = other.reindex(index=common, copy=False)
lvals = left.values
rvals = right.values
rvals = right._values
else:
left = self
lvals = self.values
Expand Down Expand Up @@ -1891,7 +1891,7 @@ def to_records(
if index:
if isinstance(self.index, MultiIndex):
# array of tuples to numpy cols. copy copy copy
ix_vals = list(map(np.array, zip(*self.index.values)))
ix_vals = list(map(np.array, zip(*self.index._values)))
else:
ix_vals = [self.index.values]

Expand Down Expand Up @@ -3009,7 +3009,7 @@ def _setitem_frame(self, key, value):
raise ValueError("Array conditional must be same shape as self")
key = self._constructor(key, **self._construct_axes_dict())

if key.values.size and not is_bool_dtype(key.values):
if key.size and not is_bool_dtype(key.values):
raise TypeError(
"Must pass DataFrame or 2-d ndarray with boolean values only"
)
Expand Down Expand Up @@ -7450,7 +7450,7 @@ def applymap(self, func) -> "DataFrame":
def infer(x):
if x.empty:
return lib.map_infer(x, func)
return lib.map_infer(x.astype(object).values, func)
return lib.map_infer(x.astype(object)._values, func)

return self.apply(infer)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4980,7 +4980,7 @@ def sample(
else:
raise ValueError("Invalid weights: weights sum to zero")

weights = weights.values
weights = weights._values

# If no frac or n, default to n=1.
if n is None and frac is None:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ def nth(self, n: Union[int, List[int]], dropna: Optional[str] = None) -> DataFra

grb = dropped.groupby(grouper, as_index=self.as_index, sort=self.sort)
sizes, result = grb.size(), grb.nth(n)
mask = (sizes < max_len).values
mask = (sizes < max_len)._values

# set the results which don't meet the criteria
if len(result) and mask.any():
Expand Down
8 changes: 5 additions & 3 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,15 @@ def astype(self, dtype, copy=True):
elif is_categorical_dtype(dtype):
from pandas.core.indexes.category import CategoricalIndex

return CategoricalIndex(self.values, name=self.name, dtype=dtype, copy=copy)
return CategoricalIndex(
self._values, name=self.name, dtype=dtype, copy=copy
)

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

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

def _format_with_header(self, header, na_rep="NaN", **kwargs):
values = self.values
values = self._values

from pandas.io.formats.format import format_array

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def to_series(self, keep_tz=lib.no_default, index=None, name=None):
# preserve the tz & copy
values = self.copy(deep=True)
else:
values = self.values.copy()
values = self._values.view("M8[ns]").copy()

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

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ def is_monotonic_increasing(self) -> bool:

# reversed() because lexsort() wants the most significant key last.
values = [
self._get_level_values(i).values for i in reversed(range(len(self.levels)))
self._get_level_values(i)._values for i in reversed(range(len(self.levels)))
]
try:
sort_order = np.lexsort(values)
Expand Down Expand Up @@ -2455,7 +2455,7 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):
"tolerance not implemented yet for MultiIndex"
)
indexer = self._engine.get_indexer(
values=self.values, target=target, method=method, limit=limit
values=self._values, target=target, method=method, limit=limit
)
elif method == "nearest":
raise NotImplementedError(
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def _homogenize(data, index, dtype: Optional[DtypeObj]):
val = com.dict_compat(val)
else:
val = dict(val)
val = lib.fast_multiget(val, oindex.values, default=np.nan)
val = lib.fast_multiget(val, oindex._values, default=np.nan)
val = sanitize_array(
val, index, dtype=dtype, copy=False, raise_cast_failure=False
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def get_axe(block, qs, axes):
b.mgr_locs = sb.mgr_locs

else:
new_axes[axis] = Index(np.concatenate([ax.values for ax in axes]))
new_axes[axis] = Index(np.concatenate([ax._values for ax in axes]))

if transposed:
new_axes = new_axes[::-1]
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _iter_data(self, data=None, keep_index=False, fillna=None):
yield col, values.values

@property
def nseries(self):
def nseries(self) -> int:
if self.data.ndim == 1:
return 1
else:
Expand Down