Skip to content

Commit c2d9dab

Browse files
committed
DEPR: pandas.core for groupby
1 parent 55cd96a commit c2d9dab

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

pandas/core/common.py

+12
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,15 @@ def fill_missing_names(names: Sequence[Hashable | None]) -> list[Hashable]:
650650
list of column names with the None values replaced.
651651
"""
652652
return [f"level_{i}" if name is None else name for i, name in enumerate(names)]
653+
654+
655+
def _depr_core() -> None:
656+
warnings.warn(
657+
"pandas.core is deprecated and has been renamed to "
658+
"pandas._core. Accessing `_core` directly is discouraged as "
659+
"members can change without warning. You should use a public module "
660+
"instead that exports the attribute in question. If you still would "
661+
"like to access an attribute from it, please use pandas._core.",
662+
DeprecationWarning,
663+
stacklevel=3,
664+
)

pandas/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ subdir('_libs')
2626

2727
subdirs_list = [
2828
'_config',
29+
'_core',
2930
'_testing',
3031
'api',
3132
'arrays',

pandas/tests/api/test_api.py

+20
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,23 @@ def test_pandas_array_alias():
381381
res = pd.arrays.PandasArray
382382

383383
assert res is pd.arrays.NumpyExtensionArray
384+
385+
386+
@pytest.mark.parametrize("submodule_name", ["groupby"])
387+
def test_depr_pandas_core_submodule(submodule_name):
388+
# GH#27522
389+
390+
submodule = getattr(pd._core, submodule_name)
391+
warning_msg = "pandas.core is deprecated"
392+
for submodule_member_name in dir(submodule):
393+
if submodule_member_name.startswith("__") and submodule_member_name.endswith(
394+
"__"
395+
):
396+
continue
397+
submodule_member = getattr(submodule, submodule_member_name)
398+
with tm.assert_produces_warning(DeprecationWarning, match=warning_msg):
399+
core_submodule = __import__(
400+
f"pandas.core.{submodule_name}", fromlist=[submodule_member_name]
401+
)
402+
with tm.assert_produces_warning(DeprecationWarning, match=warning_msg):
403+
assert submodule_member is getattr(core_submodule, submodule_member_name)

scripts/validate_unwanted_patterns.py

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
"_iLocIndexer",
5656
# TODO(3.0): GH#55043 - remove upon removal of ArrayManager
5757
"_get_option",
58+
# GH#27522
59+
"_depr_core",
5860
}
5961

6062

0 commit comments

Comments
 (0)