Skip to content

Commit 3ccdc5b

Browse files
authored
DEPR: create_block_manager_from_blocks (#55355)
* DEPR: create_block_manager_from_blocks * lint fixup
1 parent a83f6aa commit 3ccdc5b

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

pandas/core/internals/__init__.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from pandas.core.internals.managers import (
1717
BlockManager,
1818
SingleBlockManager,
19-
create_block_manager_from_blocks,
2019
)
2120

2221
__all__ = [
@@ -31,8 +30,6 @@
3130
"SingleBlockManager",
3231
"SingleArrayManager",
3332
"concatenate_managers",
34-
# this is preserved here for downstream compatibility (GH-33892)
35-
"create_block_manager_from_blocks",
3633
]
3734

3835

@@ -41,6 +38,18 @@ def __getattr__(name: str):
4138

4239
from pandas.util._exceptions import find_stack_level
4340

41+
if name == "create_block_manager_from_blocks":
42+
# GH#33892
43+
warnings.warn(
44+
f"{name} is deprecated and will be removed in a future version. "
45+
"Use public APIs instead.",
46+
DeprecationWarning,
47+
stacklevel=find_stack_level(),
48+
)
49+
from pandas.core.internals.managers import create_block_manager_from_blocks
50+
51+
return create_block_manager_from_blocks
52+
4453
if name in ["NumericBlock", "ObjectBlock"]:
4554
warnings.warn(
4655
f"{name} is deprecated and will be removed in a future version. "

pandas/tests/internals/test_api.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import pandas as pd
7+
import pandas._testing as tm
78
from pandas.core import internals
89
from pandas.core.internals import api
910

@@ -37,7 +38,6 @@ def test_namespace():
3738
"SingleBlockManager",
3839
"SingleArrayManager",
3940
"concatenate_managers",
40-
"create_block_manager_from_blocks",
4141
]
4242

4343
result = [x for x in dir(internals) if not x.startswith("__")]
@@ -51,3 +51,15 @@ def test_make_block_2d_with_dti():
5151

5252
assert blk.shape == (1, 3)
5353
assert blk.values.shape == (1, 3)
54+
55+
56+
def test_create_block_manager_from_blocks_deprecated():
57+
# GH#33892
58+
# If they must, downstream packages should get this from internals.api,
59+
# not internals.
60+
msg = (
61+
"create_block_manager_from_blocks is deprecated and will be "
62+
"removed in a future version. Use public APIs instead"
63+
)
64+
with tm.assert_produces_warning(DeprecationWarning, match=msg):
65+
internals.create_block_manager_from_blocks

0 commit comments

Comments
 (0)