diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 06bf2e5d7b18e..5fae48ae5d4b2 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -99,9 +99,6 @@ class Block(PandasObject): __slots__ = ["_mgr_locs", "values", "ndim"] is_numeric = False is_float = False - is_datetime = False - is_datetimetz = False - is_timedelta = False is_bool = False is_object = False is_extension = False @@ -213,11 +210,6 @@ def is_view(self) -> bool: def is_categorical(self) -> bool: return self._holder is Categorical - @property - def is_datelike(self) -> bool: - """ return True if I am a non-datelike """ - return self.is_datetime or self.is_timedelta - def external_values(self): """ The array that Series.values returns (public attribute). @@ -547,7 +539,8 @@ def _maybe_downcast(self, blocks: List[Block], downcast=None) -> List[Block]: # no need to downcast our float # unless indicated - if downcast is None and (self.is_float or self.is_datelike): + if downcast is None and self.dtype.kind in ["f", "m", "M"]: + # TODO: complex? more generally, self._can_hold_na? return blocks return extend_blocks([b.downcast(downcast) for b in blocks]) @@ -634,13 +627,12 @@ def astype(self, dtype, copy: bool = False, errors: str = "raise"): raise newb = self.make_block(new_values) - if newb.is_numeric and self.is_numeric: - if newb.shape != self.shape: - raise TypeError( - f"cannot set astype for copy = [{copy}] for dtype " - f"({self.dtype.name} [{self.shape}]) to different shape " - f"({newb.dtype.name} [{newb.shape}])" - ) + if newb.shape != self.shape: + raise TypeError( + f"cannot set astype for copy = [{copy}] for dtype " + f"({self.dtype.name} [{self.shape}]) to different shape " + f"({newb.dtype.name} [{newb.shape}])" + ) return newb def _astype(self, dtype: DtypeObj, copy: bool) -> ArrayLike: @@ -2089,7 +2081,6 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeBlock): values: DatetimeArray __slots__ = () - is_datetimetz = True is_extension = True _holder = DatetimeArray @@ -2167,7 +2158,7 @@ def get_values(self, dtype: Optional[DtypeObj] = None) -> np.ndarray: def external_values(self): # NB: this is different from np.asarray(self.values), since that # return an object-dtype ndarray of Timestamps. - # avoid FutureWarning in .astype in casting from dt64t to dt64 + # Avoid FutureWarning in .astype in casting from dt64tz to dt64 return self.values._data def fillna( @@ -2208,7 +2199,6 @@ def _check_ndim(self, values, ndim): class TimeDeltaBlock(DatetimeLikeBlockMixin): __slots__ = () - is_timedelta = True _can_hold_na = True is_numeric = False _holder = TimedeltaArray diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py index 01d8cde3e9af2..c65d104021a47 100644 --- a/pandas/core/internals/concat.py +++ b/pandas/core/internals/concat.py @@ -12,7 +12,6 @@ from pandas.core.dtypes.cast import ensure_dtype_can_hold_na, find_common_type from pandas.core.dtypes.common import ( - is_categorical_dtype, is_datetime64tz_dtype, is_dtype_equal, is_extension_array_dtype, @@ -295,8 +294,6 @@ def get_reindexed_values(self, empty_dtype: DtypeObj, upcasted_na) -> ArrayLike: # TODO(EA2D): special case unneeded with 2D EAs i8values = np.full(self.shape[1], fill_value.value) return DatetimeArray(i8values, dtype=empty_dtype) - elif is_categorical_dtype(blk_dtype): - pass elif is_extension_array_dtype(blk_dtype): pass elif is_extension_array_dtype(empty_dtype):