Skip to content

Commit c85f5f2

Browse files
authored
CLN: trim unnecessary checks (#32643)
1 parent ef7e720 commit c85f5f2

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

pandas/core/indexes/datetimelike.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
is_list_like,
2323
is_period_dtype,
2424
is_scalar,
25-
needs_i8_conversion,
2625
)
2726
from pandas.core.dtypes.concat import concat_compat
2827
from pandas.core.dtypes.generic import ABCIndex, ABCIndexClass, ABCSeries
@@ -484,7 +483,7 @@ def where(self, cond, other=None):
484483

485484
if is_categorical_dtype(other):
486485
# e.g. we have a Categorical holding self.dtype
487-
if needs_i8_conversion(other.categories):
486+
if is_dtype_equal(other.categories.dtype, self.dtype):
488487
other = other._internal_get_values()
489488

490489
if not is_dtype_equal(self.dtype, other.dtype):

pandas/core/internals/blocks.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -2287,11 +2287,7 @@ def to_native_types(
22872287
return np.atleast_2d(result)
22882288

22892289
def should_store(self, value) -> bool:
2290-
return (
2291-
issubclass(value.dtype.type, np.datetime64)
2292-
and not is_datetime64tz_dtype(value)
2293-
and not is_extension_array_dtype(value)
2294-
)
2290+
return is_datetime64_dtype(value.dtype)
22952291

22962292
def set(self, locs, values):
22972293
"""
@@ -2539,9 +2535,7 @@ def fillna(self, value, **kwargs):
25392535
return super().fillna(value, **kwargs)
25402536

25412537
def should_store(self, value) -> bool:
2542-
return issubclass(
2543-
value.dtype.type, np.timedelta64
2544-
) and not is_extension_array_dtype(value)
2538+
return is_timedelta64_dtype(value.dtype)
25452539

25462540
def to_native_types(self, slicer=None, na_rep=None, quoting=None, **kwargs):
25472541
""" convert to our native types format, slicing if desired """

0 commit comments

Comments
 (0)