Table Of Contents

Search

Enter search terms or a module, class or function name.

pandas.MultiIndex.get_loc

MultiIndex.get_loc(key, method=None)[source]

Get integer location, slice or boolean mask for requested label or tuple. If the key is past the lexsort depth, the return may be a boolean mask array, otherwise it is always a slice or int.

Parameters:

key : label or tuple

method : None

Returns:

loc : int, slice object or boolean mask

See also

Index.get_loc
get_loc method for (single-level) index.
get_locs
Given a tuple of slices/lists/labels/boolean indexer to a level-wise spec, produce an indexer to extract those locations.

Examples

>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')])
>>> mi.get_loc('b')
slice(1, 3, None)
>>> mi.get_loc(('b', 'e'))
1
Scroll To Top