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

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Dec 28, 2020

Users that do e.g. [getattr(pd.DataFrame, x) for x in dir(pd.DataFrame())] or inspect.getmembers(pd.DataFrame()) currently get an unfriendly deprecation warning. This fixes that by adding _AXIS_NAMES & _AXIS_NUMBERS to _hidden_attrs.

@JSunRae, is it possible for you to add this to your pandas source code and see if this fixes your problem?

xref: #33637

@jorisvandenbossche jorisvandenbossche added this to the 1.2.1 milestone Dec 28, 2020
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment on lines 339 to 343
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)
# some versions may give FutureWarning, others DeprecationWarning
assert not len(wrn)
Copy link
Member

Choose a reason for hiding this comment

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

This seems like unrelated to the actual test for constructor_expanddim. Maybe split it in two separate tests?

@simonjayhawkins simonjayhawkins added the Deprecate Functionality to remove in pandas label Dec 28, 2020
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

We could maybe add a small 1.2.1 whatsnew note, not sure if it is worth it

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.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

i think a note is warrented here in 1.2.1 in the deprecation section is fine

@topper-123
Copy link
Contributor Author

Updated.

@jreback jreback merged commit 6210077 into pandas-dev:master Dec 28, 2020
@jreback
Copy link
Contributor

jreback commented Dec 28, 2020

thanks @topper-123 very nice!

@jreback
Copy link
Contributor

jreback commented Dec 28, 2020

@meeseeksdev backport 1.2.x

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Dec 28, 2020
@topper-123 topper-123 deleted the hide_deprecated_attrs branch December 28, 2020 20:12
jreback pushed a commit that referenced this pull request Dec 28, 2020
…UMBERS (#38755)

Co-authored-by: Terji Petersen <contribute@tensortable.com>
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FutureWarning: _AXIS_NAMES has been deprecated.
4 participants