Index.slice_indexer(start: Hashable | None = None, end: Hashable | None = None, step: int | None = None) slice[source]#

Compute the slice indexer for input labels and step.

Index needs to be ordered and unique.

  • start (label, default None) – If None, defaults to the beginning.

  • end (label, default None) – If None, defaults to the end.

  • step (int, default None) –

Return type


:raises KeyError : If key does not exist, or key is not unique and index is: not ordered.


This function assumes that the data is sorted, so use at your own peril


This is a method on all index types. For example you can do:

>>> idx = pd.Index(list('abcd'))  
>>> idx.slice_indexer(start='b', end='c')  
slice(1, 3, None)
>>> idx = pd.MultiIndex.from_arrays([list('abcd'), list('efgh')])  
>>> idx.slice_indexer(start='b', end=('c', 'g'))  
slice(1, 3, None)


This method has not been implemented yet. Xorbits will try to execute it with pandas.

This docstring was copied from pandas.core.indexes.base.Index.