Skip to content

CLN: trim unnecessary checks #32643

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 12, 2020
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
3 changes: 1 addition & 2 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
is_list_like,
is_period_dtype,
is_scalar,
needs_i8_conversion,
)
from pandas.core.dtypes.concat import concat_compat
from pandas.core.dtypes.generic import ABCIndex, ABCIndexClass, ABCSeries
Expand Down Expand Up @@ -484,7 +483,7 @@ def where(self, cond, other=None):

if is_categorical_dtype(other):
# e.g. we have a Categorical holding self.dtype
if needs_i8_conversion(other.categories):
if is_dtype_equal(other.categories.dtype, self.dtype):
other = other._internal_get_values()

if not is_dtype_equal(self.dtype, other.dtype):
Expand Down
10 changes: 2 additions & 8 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2284,11 +2284,7 @@ def to_native_types(
return np.atleast_2d(result)

def should_store(self, value) -> bool:
return (
issubclass(value.dtype.type, np.datetime64)
and not is_datetime64tz_dtype(value)
and not is_extension_array_dtype(value)
)
return is_datetime64_dtype(value.dtype)

def set(self, locs, values):
"""
Expand Down Expand Up @@ -2536,9 +2532,7 @@ def fillna(self, value, **kwargs):
return super().fillna(value, **kwargs)

def should_store(self, value) -> bool:
return issubclass(
value.dtype.type, np.timedelta64
) and not is_extension_array_dtype(value)
return is_timedelta64_dtype(value.dtype)

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