pandas.Series.swaplevel
pandas 3.1.1 · Series and accessors · method
Exchange two levels of a hierarchical index.
Call syntax
Series.swaplevel(i=-2, j=-1, copy=…)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 or str |
j |
Optional Positional or keyword Default -1 |
int or str |
copy |
Optional Positional or keyword |
bool Control whether data is copied where the API supports that choice. |
Returns
Series