Skip to content

CLN: remove unreachable _internal_get_values in blocks #32472

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
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
12 changes: 5 additions & 7 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3144,14 +3144,15 @@ def _safe_reshape(arr, new_shape):
return arr


def _putmask_smart(v, mask, n):
def _putmask_smart(v: np.ndarray, mask: np.ndarray, n) -> np.ndarray:
"""
Return a new ndarray, try to preserve dtype if possible.

Parameters
----------
v : `values`, updated in-place (array like)
mask : np.ndarray
v : np.ndarray
`values`, updated in-place.
mask : np.ndarray[bool]
Applies to both sides (array like).
n : `new values` either scalar or an array like aligned with `values`

Expand Down Expand Up @@ -3218,9 +3219,6 @@ def _putmask_preserve(nv, n):
# change the dtype if needed
dtype, _ = maybe_promote(n.dtype)

if is_extension_array_dtype(v.dtype) and is_object_dtype(dtype):
v = v._internal_get_values(dtype)
else:
v = v.astype(dtype)
v = v.astype(dtype)

return _putmask_preserve(v, n)