pandas.MultiIndex.get_loc_level
pandas 3.1.1 · Index objects · method
Locate a key at a MultiIndex level and obtain the corresponding reduced index where possible.
Call syntax
MultiIndex.get_loc_level(key, level=0, drop_level=True)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
key |
Required Positional or keyword |
label or sequence of labels Provide the lookup key, or a transformation callable for a sorting method. |
level |
Optional Positional or keyword Default 0 |
int/level name or list thereof Choose an index level by name or integer position. |
drop_level |
Optional Positional or keyword Default True |
bool Choose whether selected hierarchical levels are removed from the resulting index. |
Returns
tuple