@@ -128,9 +128,6 @@ class Block(PandasObject):
128
128
__slots__ = ["_mgr_locs" , "values" , "ndim" ]
129
129
is_numeric = False
130
130
is_float = False
131
- is_datetime = False
132
- is_datetimetz = False
133
- is_timedelta = False
134
131
is_bool = False
135
132
is_object = False
136
133
is_extension = False
@@ -242,11 +239,6 @@ def is_view(self) -> bool:
242
239
def is_categorical (self ) -> bool :
243
240
return self ._holder is Categorical
244
241
245
- @property
246
- def is_datelike (self ) -> bool :
247
- """ return True if I am a non-datelike """
248
- return self .is_datetime or self .is_timedelta
249
-
250
242
def external_values (self ):
251
243
"""
252
244
The array that Series.values returns (public attribute).
@@ -576,7 +568,8 @@ def _maybe_downcast(self, blocks: List[Block], downcast=None) -> List[Block]:
576
568
577
569
# no need to downcast our float
578
570
# unless indicated
579
- if downcast is None and (self .is_float or self .is_datelike ):
571
+ if downcast is None and self .dtype .kind in ["f" , "m" , "M" ]:
572
+ # TODO: complex? more generally, self._can_hold_na?
580
573
return blocks
581
574
582
575
return extend_blocks ([b .downcast (downcast ) for b in blocks ])
@@ -663,13 +656,12 @@ def astype(self, dtype, copy: bool = False, errors: str = "raise"):
663
656
raise
664
657
665
658
newb = self .make_block (new_values )
666
- if newb .is_numeric and self .is_numeric :
667
- if newb .shape != self .shape :
668
- raise TypeError (
669
- f"cannot set astype for copy = [{ copy } ] for dtype "
670
- f"({ self .dtype .name } [{ self .shape } ]) to different shape "
671
- f"({ newb .dtype .name } [{ newb .shape } ])"
672
- )
659
+ if newb .shape != self .shape :
660
+ raise TypeError (
661
+ f"cannot set astype for copy = [{ copy } ] for dtype "
662
+ f"({ self .dtype .name } [{ self .shape } ]) to different shape "
663
+ f"({ newb .dtype .name } [{ newb .shape } ])"
664
+ )
673
665
return newb
674
666
675
667
def _astype (self , dtype : DtypeObj , copy : bool ) -> ArrayLike :
@@ -2118,7 +2110,6 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeBlock):
2118
2110
values : DatetimeArray
2119
2111
2120
2112
__slots__ = ()
2121
- is_datetimetz = True
2122
2113
is_extension = True
2123
2114
2124
2115
_holder = DatetimeArray
@@ -2196,7 +2187,7 @@ def get_values(self, dtype: Optional[DtypeObj] = None) -> np.ndarray:
2196
2187
def external_values (self ):
2197
2188
# NB: this is different from np.asarray(self.values), since that
2198
2189
# return an object-dtype ndarray of Timestamps.
2199
- # avoid FutureWarning in .astype in casting from dt64t to dt64
2190
+ # Avoid FutureWarning in .astype in casting from dt64tz to dt64
2200
2191
return self .values ._data
2201
2192
2202
2193
def fillna (
@@ -2237,7 +2228,6 @@ def _check_ndim(self, values, ndim):
2237
2228
2238
2229
class TimeDeltaBlock (DatetimeLikeBlockMixin ):
2239
2230
__slots__ = ()
2240
- is_timedelta = True
2241
2231
_can_hold_na = True
2242
2232
is_numeric = False
2243
2233
_holder = TimedeltaArray
0 commit comments