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

Comments

Projects
None yet
2 participants
@brandon-rhodes
Contributor

brandon-rhodes commented Apr 20, 2016

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

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Apr 20, 2016

Contributor

@brandon-rhodes yes this does seem ok

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 closed this in ed324e8 Apr 22, 2016

@jreback jreback modified the milestones: 0.18.1, Next Major Release Apr 22, 2016

nps added a commit to nps/pandas that referenced this issue May 17, 2016

Add defaults to swaplevel() parameters i and j
Closes pandas-dev#12934 feature request.

Author: Brandon Rhodes <brandon@rhodesmill.org>

Closes pandas-dev#12943 from brandon-rhodes/master and squashes the following commits:

c6fbb3e [Brandon Rhodes] Add default values to swaplevel() i, j parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment