Skip to content
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

DEPR: Hide deprecated attrs _AXIS_NAMES & _AXIS_NUMBERS #38740

Merged
merged 5 commits into from
Dec 28, 2020
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
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.2.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ including other versions of pandas.

Fixed regressions
~~~~~~~~~~~~~~~~~
-
- The deprecated attributes ``_AXIS_NAMES`` and ``_AXIS_NUMBERS`` of :class:`DataFrame` and :class:`Series` will no longer show up in ``dir`` or ``inspect.getmembers`` calls (:issue:`38740`)
-

.. ---------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ class NDFrame(PandasObject, SelectionMixin, indexing.IndexingMixin):
]
_internal_names_set: Set[str] = set(_internal_names)
_accessors: Set[str] = set()
_hidden_attrs: FrozenSet[str] = frozenset(["get_values", "tshift"])
_hidden_attrs: FrozenSet[str] = frozenset(
["_AXIS_NAMES", "_AXIS_NUMBERS", "get_values", "tshift"]
)
_metadata: List[str] = []
_is_copy = None
_mgr: BlockManager
Expand Down
17 changes: 7 additions & 10 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from copy import deepcopy
import inspect
import pydoc
import warnings

import numpy as np
import pytest
Expand Down Expand Up @@ -330,19 +329,17 @@ def test_set_flags(self, allows_duplicate_labels, frame_or_series):
result.iloc[key] = 10
assert obj.iloc[key] == 0

@skip_if_no("jinja2")
def test_constructor_expanddim_lookup(self):
# GH#33628 accessing _constructor_expanddim should not
# raise NotImplementedError
df = DataFrame()

with warnings.catch_warnings(record=True) as wrn:
# _AXIS_NUMBERS, _AXIS_NAMES lookups
inspect.getmembers(df)

# some versions give FutureWarning, others DeprecationWarning
assert len(wrn)
assert any(x.category in [FutureWarning, DeprecationWarning] for x in wrn)

with pytest.raises(NotImplementedError, match="Not supported for DataFrames!"):
df._constructor_expanddim(np.arange(27).reshape(3, 3, 3))

@skip_if_no("jinja2")
def test_inspect_getmembers(self):
# GH38740
df = DataFrame()
with tm.assert_produces_warning(None):
inspect.getmembers(df)