@@ -1244,7 +1244,7 @@ def take_nd(
1244
1244
Take values according to indexer and return them as a block.bb
1245
1245
1246
1246
"""
1247
- # algos.take_nd dispatches for DatetimeTZBlock
1247
+ # algos.take_nd dispatches for DatetimeTZBlock, CategoricalBlock
1248
1248
# so need to preserve types
1249
1249
# sparse is treated like an ndarray, but needs .get_values() shaping
1250
1250
@@ -1443,7 +1443,7 @@ class ExtensionBlock(Block):
1443
1443
Notes
1444
1444
-----
1445
1445
This holds all 3rd-party extension array types. It's also the immediate
1446
- parent class for our internal extension types' blocks.
1446
+ parent class for our internal extension types' blocks, CategoricalBlock .
1447
1447
1448
1448
ExtensionArrays are limited to 1-D.
1449
1449
"""
@@ -2017,6 +2017,11 @@ def _can_hold_element(self, element: Any) -> bool:
2017
2017
return True
2018
2018
2019
2019
2020
+ class CategoricalBlock (ExtensionBlock ):
2021
+ # this Block type is kept for backwards-compatibility
2022
+ __slots__ = ()
2023
+
2024
+
2020
2025
# -----------------------------------------------------------------
2021
2026
# Constructor Helpers
2022
2027
@@ -2078,7 +2083,7 @@ def get_block_type(values, dtype: Optional[Dtype] = None):
2078
2083
# Need this first(ish) so that Sparse[datetime] is sparse
2079
2084
cls = ExtensionBlock
2080
2085
elif isinstance (dtype , CategoricalDtype ):
2081
- cls = ExtensionBlock
2086
+ cls = CategoricalBlock
2082
2087
elif vtype is Timestamp :
2083
2088
cls = DatetimeTZBlock
2084
2089
elif vtype is Interval or vtype is Period :
0 commit comments