A RetroSearch Logo

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

Search Query:

Showing content from https://pandas.pydata.org/docs/dev/user_guide/../reference/api/pandas.MultiIndex.swaplevel.html below:

pandas.MultiIndex.swaplevel — pandas 3.0.0.dev0+2231.g4f2aa4d2be documentation

pandas.MultiIndex.swaplevel#
MultiIndex.swaplevel(i=-2, j=-1)[source]#

Swap level i with level j.

Calling this method does not change the ordering of the values.

Parameters:
iint, str, default -2

First level of index to be swapped. Can pass level name as string. Type of parameters can be mixed.

jint, str, default -1

Second level of index to be swapped. Can pass level name as string. Type of parameters can be mixed.

Returns:
MultiIndex

A new MultiIndex.

Examples

>>> mi = pd.MultiIndex(
...     levels=[["a", "b"], ["bb", "aa"]], codes=[[0, 0, 1, 1], [0, 1, 0, 1]]
... )
>>> mi
MultiIndex([('a', 'bb'),
            ('a', 'aa'),
            ('b', 'bb'),
            ('b', 'aa')],
           )
>>> mi.swaplevel(0, 1)
MultiIndex([('bb', 'a'),
            ('aa', 'a'),
            ('bb', 'b'),
            ('aa', 'b')],
           )

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