Skip to content

Commit 7aa66d5

Browse files
committed
CLN: deprecate ObjectBlock and NumericBlock
1 parent 8cc7df2 commit 7aa66d5

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

pandas/core/internals/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,28 @@
3636
# this is preserved here for downstream compatibility (GH-33892)
3737
"create_block_manager_from_blocks",
3838
]
39+
40+
41+
def __getattr__(name: str):
42+
import warnings
43+
44+
from pandas.util._exceptions import find_stack_level
45+
46+
if name in ["NumericBlock", "ObjectBlock"]:
47+
if name == "NumericBlock":
48+
from pandas.core.internals.blocks import NumericBlock
49+
50+
block_type = NumericBlock
51+
elif name == "ObjectBlock":
52+
from pandas.core.internals.blocks import ObjectBlock
53+
54+
block_type = ObjectBlock
55+
warnings.warn(
56+
f"{name} is deprecated and will be removed in a future version. "
57+
"Use NumpyBlock instead.",
58+
DeprecationWarning,
59+
stacklevel=find_stack_level(),
60+
)
61+
return block_type
62+
63+
raise AttributeError(f"module 'pandas.core.internals' has no attribute '{name}'")

pandas/core/internals/blocks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,16 @@ def is_object(self) -> bool:
21532153
return self.values.dtype.kind == "O"
21542154

21552155

2156+
class NumericBlock(NumpyBlock):
2157+
# this Block type is kept for backwards-compatibility
2158+
__slots__ = ()
2159+
2160+
2161+
class ObjectBlock(NumpyBlock):
2162+
# this Block type is kept for backwards-compatibility
2163+
__slots__ = ()
2164+
2165+
21562166
class NDArrayBackedExtensionBlock(libinternals.NDArrayBackedBlock, EABackedBlock):
21572167
"""
21582168
Block backed by an NDArrayBackedExtensionArray

0 commit comments

Comments
 (0)