pandas 1.4.2

ParametersReturns
get_loc_level(self, key, level=0, drop_level: 'bool' = True)

Parameters

key : label or sequence of labels
level : int/level name or list thereof, optional
drop_level : bool, default True

If False , the resulting index will not drop any level.

Returns

loc : A 2-tuple where the elements are:

Element 0: int, slice object or boolean array Element 1: The resulting sliced multiindex/index. If the key contains all levels, this will be None .

Get location and sliced index for requested label(s)/level(s).

See Also

MultiIndex.get_loc

Get location for a label or a tuple of labels.

MultiIndex.get_locs

Get location for a label/slice/list/mask or a sequence of such.

Examples

This example is valid syntax, but we were not able to check execution
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')],
...  names=['A', 'B'])
This example is valid syntax, but we were not able to check execution
>>> mi.get_loc_level('b')
(slice(1, 3, None), Index(['e', 'f'], dtype='object', name='B'))
This example is valid syntax, but we were not able to check execution
>>> mi.get_loc_level('e', level='B')
(array([False,  True, False]), Index(['b'], dtype='object', name='A'))
This example is valid syntax, but we were not able to check execution
>>> mi.get_loc_level(['b', 'e'])
(1, None)
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/indexes/multi.py#2929
type: <class 'function'>
Commit: