Skip to content

CLN: avoid values_from_object in NDFrame #32422

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 1 commit into from
Mar 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ def equals(self, other):
# Unary Methods

def __neg__(self):
values = com.values_from_object(self)
values = self._values
if is_bool_dtype(values):
arr = operator.inv(values)
elif (
Expand All @@ -1341,7 +1341,7 @@ def __neg__(self):
return self.__array_wrap__(arr)

def __pos__(self):
values = com.values_from_object(self)
values = self._values
if is_bool_dtype(values) or is_period_arraylike(values):
arr = values
elif (
Expand Down Expand Up @@ -1796,7 +1796,7 @@ def empty(self) -> bool_t:
__array_priority__ = 1000

def __array__(self, dtype=None) -> np.ndarray:
return com.values_from_object(self)
return np.asarray(self._values, dtype=dtype)

def __array_wrap__(self, result, context=None):
result = lib.item_from_zerodim(result)
Expand Down Expand Up @@ -8521,7 +8521,7 @@ def _where(

# try to not change dtype at first (if try_quick)
if try_quick:
new_other = com.values_from_object(self)
new_other = np.asarray(self)
new_other = new_other.copy()
new_other[icond] = other
other = new_other
Expand Down