Skip to content

ENH: level keyword in rename (GH4160) #13766

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

Conversation

jorisvandenbossche
Copy link
Member


"""
if isinstance(index, MultiIndex):
items = [tuple(func(y) for y in x) for x in index]
if level is not None:
items = [tuple(func(y) if i == level else y
Copy link
Contributor

Choose a reason for hiding this comment

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

this shoukd be in a rename method in Index
MI should also just iterate in the levels and call rename on that Index

should not be in internals

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, that's how rename is implemented at the moment ..
And AFAIK there is not a rename method on Index itself? (there is, but that is to change the name attribute, so something else)

Copy link
Contributor

Choose a reason for hiding this comment

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

no I mean move it there
much cleaner to do it

Copy link
Member Author

Choose a reason for hiding this comment

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

So I mean this comment. Do you mean it would be cleaner to have a method on Index/MultiIndex itself that does this renaming?
I can agree with that, but the problem is that there already is a 'rename' method which renames the names of a multi index (it could of course also be a private method)

But my preference is to leave the existing implementation intact in this PR (I just expanded the existing method a bit).

Copy link
Contributor

Choose a reason for hiding this comment

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

yes I mean move this to MultiIndex, and create a corresponding (private is fine) one for Index. ideally it would be rename, but I guess has to be a private method.

@jreback jreback modified the milestones: 0.20.0, 0.19.0 Aug 18, 2016
@jreback
Copy link
Contributor

jreback commented Nov 16, 2016

this looks pretty good. maybe rebase and see where we are.

@jreback
Copy link
Contributor

jreback commented Feb 1, 2017

@jorisvandenbossche ?

@jorisvandenbossche
Copy link
Member Author

Trying to revive this. @jreback I am not sure anymore what was missing before, but can you clarify your comment a bit?

@jorisvandenbossche jorisvandenbossche force-pushed the rename-level branch 3 times, most recently from 2df75a3 to 0065973 Compare April 12, 2017 16:42
@codecov
Copy link

codecov bot commented Apr 12, 2017

Codecov Report

Merging #13766 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13766      +/-   ##
==========================================
+ Coverage      91%      91%   +<.01%     
==========================================
  Files         145      145              
  Lines       49581    49586       +5     
==========================================
+ Hits        45122    45128       +6     
+ Misses       4459     4458       -1
Flag Coverage Δ
#multiple 88.77% <100%> (ø) ⬆️
#single 40.57% <60%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/internals.py 93.55% <100%> (ø) ⬆️
pandas/core/generic.py 96.26% <100%> (ø) ⬆️
pandas/core/common.py 90.68% <0%> (-0.35%) ⬇️
pandas/util/testing.py 81.13% <0%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1751628...0065973. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 12, 2017

Codecov Report

Merging #13766 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13766      +/-   ##
==========================================
+ Coverage   90.99%   90.99%   +<.01%     
==========================================
  Files         153      153              
  Lines       50481    50486       +5     
==========================================
+ Hits        45937    45942       +5     
  Misses       4544     4544
Flag Coverage Δ
#multiple 88.76% <100%> (ø) ⬆️
#single 40.43% <60%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/internals.py 93.55% <100%> (ø) ⬆️
pandas/core/generic.py 96.29% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd1031f...1915696. Read the comment docs.

@jorisvandenbossche jorisvandenbossche merged commit 0ba305b into pandas-dev:master Apr 18, 2017
@jorisvandenbossche
Copy link
Member Author

@jreback I merged this, as I currently don't have time to address the clean-up comment (and I just used what was already in place). Do you find it worth to open an issue to keep track of that comment?

@jreback
Copy link
Contributor

jreback commented Apr 18, 2017

create a new issue to track this and mark it for 0.20.0 I will get to this. This impl is not consistent with how things are done internally.

@jorisvandenbossche
Copy link
Member Author

#16045

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants