Get location for a sequence of labels.
You should use one of the above for each level. If a level should not be used, set it to slice(None).
NumPy array of integers suitable for passing to iloc.
See also
MultiIndex.get_locGet location for a label or a tuple of labels.
MultiIndex.slice_locsGet slice location given start label(s) and end label(s).
Examples
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')])
>>> mi.get_locs('b')
array([1, 2], dtype=int64)
>>> mi.get_locs([slice(None), ['e', 'f']])
array([1, 2], dtype=int64)
>>> mi.get_locs([[True, False, True], slice('e', 'f')])
array([2], dtype=int64)
© 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_locs.html