Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions pandas/core/array_algos/putmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def putmask_without_repeat(
mask : np.ndarray[bool]
new : Any
"""
new = setitem_datetimelike_compat(values, mask.sum(), new)

if getattr(new, "ndim", 0) >= 1:
new = new.astype(values.dtype, copy=False)

Expand Down
8 changes: 0 additions & 8 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
Shape,
npt,
)
from pandas.compat import np_version_under1p20
from pandas.util._decorators import cache_readonly
from pandas.util._exceptions import find_stack_level
from pandas.util._validators import validate_bool_kwarg
Expand All @@ -39,7 +38,6 @@
from pandas.core.dtypes.cast import (
can_hold_element,
find_result_type,
infer_dtype_from,
maybe_downcast_numeric,
maybe_downcast_to_dtype,
soft_convert_objects,
Expand Down Expand Up @@ -988,12 +986,6 @@ def putmask(self, mask, new) -> list[Block]:
putmask_without_repeat(values.T, mask, new)
return [self]

elif np_version_under1p20 and infer_dtype_from(new)[0].kind in ["m", "M"]:
# using putmask with object dtype will incorrectly cast to object
# Having excluded self._can_hold_element, we know we cannot operate
# in-place, so we are safe using `where`
return self.where(new, ~mask)

elif noop:
return [self]

Expand Down