pandas.MultiIndex.swaplevel
pandas 3.1.1 · Index objects · method
Exchange two levels of a hierarchical index.
Call syntax
MultiIndex.swaplevel(i=-2, j=-1)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
i |
Optional Positional or keyword Default -2 |
int, str |
j |
Optional Positional or keyword Default -1 |
int, str |
Returns
MultiIndex