@@ -100,8 +100,6 @@ class Block(PandasObject):
100
100
__slots__ = ["_mgr_locs" , "values" , "ndim" ]
101
101
is_numeric = False
102
102
is_float = False
103
- is_integer = False
104
- is_complex = False
105
103
is_datetime = False
106
104
is_datetimetz = False
107
105
is_timedelta = False
@@ -1195,7 +1193,7 @@ def _interpolate(
1195
1193
1196
1194
# only deal with floats
1197
1195
if not self .is_float :
1198
- if not self .is_integer :
1196
+ if self .dtype . kind not in [ "i" , "u" ] :
1199
1197
return [self ]
1200
1198
data = data .astype (np .float64 )
1201
1199
@@ -1316,7 +1314,7 @@ def where(self, other, cond, errors="raise", axis: int = 0) -> List["Block"]:
1316
1314
# see if we can operate on the entire block, or need item-by-item
1317
1315
# or if we are a single block (ndim == 1)
1318
1316
if (
1319
- (self .is_integer or self . is_bool )
1317
+ (self .dtype . kind in [ "b" , "i" , "u" ] )
1320
1318
and lib .is_float (other )
1321
1319
and np .isnan (other )
1322
1320
):
@@ -1332,7 +1330,7 @@ def where(self, other, cond, errors="raise", axis: int = 0) -> List["Block"]:
1332
1330
return self ._maybe_downcast (blocks , "infer" )
1333
1331
1334
1332
if not (
1335
- (self .is_integer or self . is_bool )
1333
+ (self .dtype . kind in [ "b" , "i" , "u" ] )
1336
1334
and lib .is_float (other )
1337
1335
and np .isnan (other )
1338
1336
):
@@ -1912,11 +1910,18 @@ def external_values(self):
1912
1910
class NumericBlock (Block ):
1913
1911
__slots__ = ()
1914
1912
is_numeric = True
1915
- _can_hold_na = True
1916
1913
1917
1914
def _can_hold_element (self , element : Any ) -> bool :
1918
1915
return can_hold_element (self .dtype , element )
1919
1916
1917
+ @property
1918
+ def _can_hold_na (self ):
1919
+ return self .dtype .kind not in ["b" , "i" , "u" ]
1920
+
1921
+ @property
1922
+ def is_bool (self ):
1923
+ return self .dtype .kind == "b"
1924
+
1920
1925
1921
1926
class FloatBlock (NumericBlock ):
1922
1927
__slots__ = ()
@@ -1956,17 +1961,6 @@ def to_native_types(
1956
1961
return self .make_block (res )
1957
1962
1958
1963
1959
- class ComplexBlock (NumericBlock ):
1960
- __slots__ = ()
1961
- is_complex = True
1962
-
1963
-
1964
- class IntBlock (NumericBlock ):
1965
- __slots__ = ()
1966
- is_integer = True
1967
- _can_hold_na = False
1968
-
1969
-
1970
1964
class DatetimeLikeBlockMixin (HybridMixin , Block ):
1971
1965
"""Mixin class for DatetimeBlock, DatetimeTZBlock, and TimedeltaBlock."""
1972
1966
@@ -2232,7 +2226,7 @@ def _check_ndim(self, values, ndim):
2232
2226
return ndim
2233
2227
2234
2228
2235
- class TimeDeltaBlock (DatetimeLikeBlockMixin , IntBlock ):
2229
+ class TimeDeltaBlock (DatetimeLikeBlockMixin ):
2236
2230
__slots__ = ()
2237
2231
is_timedelta = True
2238
2232
_can_hold_na = True
@@ -2269,12 +2263,6 @@ def fillna(self, value, **kwargs):
2269
2263
return super ().fillna (value , ** kwargs )
2270
2264
2271
2265
2272
- class BoolBlock (NumericBlock ):
2273
- __slots__ = ()
2274
- is_bool = True
2275
- _can_hold_na = False
2276
-
2277
-
2278
2266
class ObjectBlock (Block ):
2279
2267
__slots__ = ()
2280
2268
is_object = True
@@ -2477,12 +2465,8 @@ def get_block_type(values, dtype: Optional[Dtype] = None):
2477
2465
cls = TimeDeltaBlock
2478
2466
elif kind == "f" :
2479
2467
cls = FloatBlock
2480
- elif kind == "c" :
2481
- cls = ComplexBlock
2482
- elif kind == "i" or kind == "u" :
2483
- cls = IntBlock
2484
- elif kind == "b" :
2485
- cls = BoolBlock
2468
+ elif kind in ["c" , "i" , "u" , "b" ]:
2469
+ cls = NumericBlock
2486
2470
else :
2487
2471
cls = ObjectBlock
2488
2472
return cls
0 commit comments