@@ -103,7 +103,6 @@ class Block(PandasObject):
103
103
is_timedelta = False
104
104
is_bool = False
105
105
is_object = False
106
- is_categorical = False
107
106
is_extension = False
108
107
_can_hold_na = False
109
108
_can_consolidate = True
@@ -183,6 +182,10 @@ def is_view(self) -> bool:
183
182
""" return a boolean if I am possibly a view """
184
183
return self .values .base is not None
185
184
185
+ @property
186
+ def is_categorical (self ) -> bool :
187
+ return self ._holder is Categorical
188
+
186
189
@property
187
190
def is_datelike (self ) -> bool :
188
191
""" return True if I am a non-datelike """
@@ -1654,12 +1657,6 @@ def iget(self, col):
1654
1657
raise IndexError (f"{ self } only contains one item" )
1655
1658
return self .values
1656
1659
1657
- def should_store (self , value : ArrayLike ) -> bool :
1658
- """
1659
- Can we set the given array-like value inplace?
1660
- """
1661
- return isinstance (value , self ._holder )
1662
-
1663
1660
def set (self , locs , values ):
1664
1661
assert locs .tolist () == [0 ]
1665
1662
self .values = values
@@ -2050,9 +2047,6 @@ def _can_hold_element(self, element: Any) -> bool:
2050
2047
element , (float , int , complex , np .float_ , np .int_ )
2051
2048
) and not isinstance (element , (bool , np .bool_ ))
2052
2049
2053
- def should_store (self , value : ArrayLike ) -> bool :
2054
- return issubclass (value .dtype .type , np .complexfloating )
2055
-
2056
2050
2057
2051
class IntBlock (NumericBlock ):
2058
2052
__slots__ = ()
@@ -2218,7 +2212,6 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeBlock):
2218
2212
_can_hold_element = DatetimeBlock ._can_hold_element
2219
2213
to_native_types = DatetimeBlock .to_native_types
2220
2214
fill_value = np .datetime64 ("NaT" , "ns" )
2221
- should_store = Block .should_store
2222
2215
array_values = ExtensionBlock .array_values
2223
2216
2224
2217
@property
@@ -2680,20 +2673,6 @@ def _replace_coerce(
2680
2673
2681
2674
class CategoricalBlock (ExtensionBlock ):
2682
2675
__slots__ = ()
2683
- is_categorical = True
2684
- _can_hold_na = True
2685
-
2686
- should_store = Block .should_store
2687
-
2688
- def __init__ (self , values , placement , ndim = None ):
2689
- # coerce to categorical if we can
2690
- values = extract_array (values )
2691
- assert isinstance (values , Categorical ), type (values )
2692
- super ().__init__ (values , placement = placement , ndim = ndim )
2693
-
2694
- @property
2695
- def _holder (self ):
2696
- return Categorical
2697
2676
2698
2677
def replace (
2699
2678
self ,
0 commit comments