Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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: 9 additions & 8 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,20 @@ 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 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()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use assert_produces_warning(None) here, but really nobd.

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))
assert not len(wrn)