Skip to content

DEPR: create_block_manager_from_blocks #55355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions pandas/core/internals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from pandas.core.internals.managers import (
BlockManager,
SingleBlockManager,
create_block_manager_from_blocks,
)

__all__ = [
Expand All @@ -31,8 +30,6 @@
"SingleBlockManager",
"SingleArrayManager",
"concatenate_managers",
# this is preserved here for downstream compatibility (GH-33892)
"create_block_manager_from_blocks",
]


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

from pandas.util._exceptions import find_stack_level

if name == "create_block_manager_from_blocks":
# GH#33892
warnings.warn(
f"{name} is deprecated and will be removed in a future version. "
"Use public APIs instead.",
DeprecationWarning,
stacklevel=find_stack_level(),
)
from pandas.core.internals.managers import create_block_manager_from_blocks

return create_block_manager_from_blocks

if name in ["NumericBlock", "ObjectBlock"]:
warnings.warn(
f"{name} is deprecated and will be removed in a future version. "
Expand Down
14 changes: 13 additions & 1 deletion pandas/tests/internals/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import pandas as pd
import pandas._testing as tm
from pandas.core import internals
from pandas.core.internals import api

Expand Down Expand Up @@ -37,7 +38,6 @@ def test_namespace():
"SingleBlockManager",
"SingleArrayManager",
"concatenate_managers",
"create_block_manager_from_blocks",
]

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

assert blk.shape == (1, 3)
assert blk.values.shape == (1, 3)


def test_create_block_manager_from_blocks_deprecated():
# GH#33892
# If they must, downstream packages should get this from internals.api,
# not internals.
msg = (
"create_block_manager_from_blocks is deprecated and will be "
"removed in a future version. Use public APIs instead"
)
with tm.assert_produces_warning(DeprecationWarning, match=msg):
internals.create_block_manager_from_blocks