-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
REF: _AXIS_TO_AXIS_NUMBER to simplify axis access #33637
Conversation
""".. deprecated:: 1.1.0""" | ||
super()._AXIS_NAMES | ||
return {0: "index", 1: "columns"} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither _AXIS_NUMBERS
and _AXIS_NAMES
are needed anymore. Just in case they are used downstream I've deprecated them instead of just removing them.
162b954
to
ab8ed31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1 on adding anything here
This is not adding things, it's moving things around and simplifying. A nice side effect will that we can now see the allowed values for |
39ba455
to
db44239
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
pandas/core/generic.py
Outdated
def _AXIS_NUMBERS(self) -> Dict[str, int]: | ||
""".. deprecated:: 1.1.0""" | ||
warnings.warn( | ||
"_AXIS_NUMBERS has been deprecated. Call ._get_axis_number instead", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably not point to another private method? (maybe just say it is deprecated, without alternative, unless we want to expose something more publicly somewhere, or document this private method as "public" for developer use)
dd76ae0
to
014b95f
Compare
014b95f
to
7932822
Compare
I've found out that this PR requires a change to the recipe on setting aliases in cookbook.rst. I quite dislike encouraging setting aliases in the official pandas docs. If anyone actually uses that pattern in real code, is would be just confusing without being helpful IMO. But I've just changed it to the new style, for now, but would prefer to delete the section on aliases if there's no objections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. ex my doc-comment above.
doc/source/user_guide/cookbook.rst
Outdated
@@ -1336,21 +1336,27 @@ Values can be set to NaT using np.nan, similar to datetime | |||
Aliasing axis names | |||
------------------- | |||
|
|||
.. versionchanged:: 1.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should just remove this section entirely. it isn't really tested / nor well supported.
Could you expand, I don't understand this comment (and maybe the first comment too). |
I think Jeff just mean to say to remove the cookbook example, alltogether, as you did (and indeed, that is not something to put in our docs I think) |
Ok. |
thanks @topper-123 very nice |
can you add the deprecations to issue for removal: #30228 |
This adds a dict called
_AXIS_TO_AXIS_NUMBER
to NDFrame/DataFrame where the keys are the allowed parameter values for theaxis
parameter in various ndframe methods and the dict values are the related axis number. This makes getting to the correct axis more straight forward, see for example the new_get_axis_number
, and makes adding type hints to theaxis
parameter easier.