Get location for a label or a tuple of labels.
The location is returned as an integer/slice or boolean mask.
If the key is past the lexsort depth, the return may be a boolean mask array, otherwise it is always a slice or int.
See also
Index.get_locThe get_loc method for (single-level) index.
MultiIndex.slice_locsGet slice location given start label(s) and end label(s).
MultiIndex.get_locsGet location for a label/slice/list/mask or a sequence of such.
Notes
The key cannot be a slice, list of same-level labels, a boolean mask, or a sequence of such. If you want to use those, use MultiIndex.get_locs() instead.
Examples
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')])
>>> mi.get_loc('b')
slice(1, 3, None)
>>> mi.get_loc(('b', 'e'))
1
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.MultiIndex.get_loc.html