8000 ENH: Allow rename_axis to specify index and columns arguments by Dr-Irv · Pull Request #20046 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: Allow rename_axis to specify index and columns arguments #20046

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

Merged
merged 19 commits into from
Oct 29, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Doc changes and resolve conflicts with master
  • Loading branch information
Dr-Irv committed Mar 8, 2018
commit a14e6a1e66a3bc74aad7f9654ec51e4508eb0fed
10000
7 changes: 5 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,10 @@ def swaplevel(self, i=-2, j=-1, axis=0):

# renamer function if passed a dict
Copy link
Member

Choose a reason for hiding this comment

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

I know you just moved the function, but let's take this opportunity to write a brief docstring.

def _get_rename_function(self, mapper):
"""
Returns a function that will map names/labels, dependent if mapper
is a dict, Series or just a function.
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't need to be here (in the class). is it used in more than 1 place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is used in both rename() and rename_axis()

Copy link
Contributor

Choose a reason for hiding this comment

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

right, but it doesn't need self right? can you move to pandas/core/common.py i think is ok for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have moved it and removed leading underscore

"""
if isinstance(mapper, (dict, ABCSeries)):

def f(x):
Expand Down Expand Up @@ -913,8 +917,7 @@ def rename(self, *args, **kwargs):
rename.__doc__ = _shared_docs['rename']

def rename_axis(self, mapper=None, **kwargs):
"""Alter the name of the index or name of index backing the
columns.
"""Alter the name of the index or name of index backing the columns.

Parameters
----------
Expand Down
0