A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/12934 below:

Add parameter defaults for swaplevel · Issue #12934 · pandas-dev/pandas · GitHub

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.

jorisvandenbossche and TomAugspurger


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4