Skip to content

Commit 32225b0

Browse files
authored
CLN: de-kluge (#37183)
1 parent 40b65da commit 32225b0

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

pandas/core/dtypes/cast.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -491,37 +491,23 @@ def maybe_casted_values(
491491
if codes is not None:
492492
mask: np.ndarray = codes == -1
493493

494-
# we can have situations where the whole mask is -1,
495-
# meaning there is nothing found in codes, so make all nan's
496494
if mask.size > 0 and mask.all():
495+
# we can have situations where the whole mask is -1,
496+
# meaning there is nothing found in codes, so make all nan's
497+
497498
dtype = index.dtype
498499
fill_value = na_value_for_dtype(dtype)
499500
values = construct_1d_arraylike_from_scalar(fill_value, len(mask), dtype)
501+
500502
else:
501503
values = values.take(codes)
502504

503-
# TODO(https://github.com/pandas-dev/pandas/issues/24206)
504-
# Push this into maybe_upcast_putmask?
505-
# We can't pass EAs there right now. Looks a bit
506-
# complicated.
507-
# So we unbox the ndarray_values, op, re-box.
508-
values_type = type(values)
509-
values_dtype = values.dtype
510-
511-
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
512-
513-
if isinstance(values, DatetimeLikeArrayMixin):
514-
values = values._data # TODO: can we de-kludge yet?
515-
516505
if mask.any():
517506
if isinstance(values, np.ndarray):
518507
values, _ = maybe_upcast_putmask(values, mask, np.nan)
519508
else:
520509
values[mask] = np.nan
521510

522-
if issubclass(values_type, DatetimeLikeArrayMixin):
523-
values = values_type(values, dtype=values_dtype)
524-
525511
return values
526512

527513

0 commit comments

Comments
 (0)