Index.
slice_indexer
Compute the slice indexer for input labels and step.
Index needs to be ordered and unique.
If None, defaults to the beginning.
If None, defaults to the end.
not ordered.
Notes
This function assumes that the data is sorted, so use at your own peril
Examples
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)