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

Add parameter defaults for swaplevel #12934

Closed
brandon-rhodes opened this issue Apr 20, 2016 · 1 comment
Closed

Add parameter defaults for swaplevel #12934

brandon-rhodes opened this issue Apr 20, 2016 · 1 comment
Labels
API Design MultiIndex Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@brandon-rhodes
Copy link
Contributor

I will be happy to write up a pull request, but first wanted to gauge the sanity of my suggestion:

I think that swaplevel() deserves default values for its parameters, just like its friends like stack() and unstack() and sortlevel() that also all take an initial level argument. I suggest:

def swaplevel(self, i=-2, j=-1, axis=0):

This provides the greatest symmetry with the other methods that operate on levels: they all, if no level is specified, operate on the innermost level as their default.

In the very common case where there are only two levels to the multi-index anyway, this would reduce this frequent operation to simply .swaplevel() or .swaplevel(axis='columns') without, I don't think, any more loss of readability than when stack() or unstack() fail to specify the level upon which they are operating.

@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode API Design MultiIndex labels Apr 20, 2016
@jreback
Copy link
Contributor

jreback commented Apr 20, 2016

@brandon-rhodes yes this does seem ok

@jreback jreback added this to the Next Major Release milestone Apr 20, 2016
@jreback jreback modified the milestones: 0.18.1, Next Major Release Apr 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design MultiIndex Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

2 participants