pandas.DataFrame.droplevel
pandas 3.1.1 · DataFrame · method
Remove one or more levels of a hierarchical index.
Call syntax
DataFrame.droplevel(level, axis=0)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
level |
Required Positional or keyword |
int, str, or list-like Choose an index level by name or integer position. |
axis |
Optional Positional or keyword Default 0 |
{0 or 'index', 1 or 'columns'} Choose which axis the operation acts on. The accepted axis labels depend on the receiver. |
Returns
Series/DataFrame