pandas / 1 / reference / api / pandas.index.slice_locs.html

pandas.Index.slice_locs

Index.slice_locs(start=None, end=None, step=None, kind=_NoDefault.no_default)[source]

Compute slice locations for input labels.

Parameters
start:label, default None

If None, defaults to the beginning.

end:label, default None

If None, defaults to the end.

step:int, defaults None

If None, defaults to 1.

kind:{‘loc’, ‘getitem’} or None

Deprecated since version 1.4.0.

Returns
start, end:int

See also

Index.get_loc

Get location for a single label.

Notes

This method only works if the index is monotonic or unique.

Examples

>>> idx = pd.Index(list('abcd'))
>>> idx.slice_locs(start='b', end='c')
(1, 3)

© 2008–2022, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.5.0/reference/api/pandas.Index.slice_locs.html