# xarray.CFTimeIndex.slice_indexer

#### CFTimeIndex.slice_indexer(start=None, end=None, step=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.15/site-packages/pandas/core/indexes/base.py#L7085-L7144)

Compute the slice indexer for input labels and step.

Index needs to be ordered and unique.

* **Parameters:**
  * **start** (`label`, *default* [`None`](https://docs.python.org/3/builtins/constants.html#None)) – If None, defaults to the beginning.
  * **end** (`label`, *default* [`None`](https://docs.python.org/3/builtins/constants.html#None)) – If None, defaults to the end.
  * **step** ([`int`](https://docs.python.org/3/builtins/functions.html#int), *default* [`None`](https://docs.python.org/3/builtins/constants.html#None)) – If None, defaults to 1.
* **Returns:**
  [`slice`](https://docs.python.org/3/builtins/functions.html#slice) – A slice object.

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

#### SEE ALSO
`Index.slice_locs`
: Computes slice locations for input labels.

`Index.get_slice_bound`
: Retrieves slice bound that corresponds to given label.

### Notes

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

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('16e68854-36f8-4fef-96a9-b49398ae71d0','2ec83c05-0d83-4e17-9872-51f1cdf99efd','12436481-200e-49af-9ace-5f4ede4b7856','../lite/tree/../notebooks/index.html?path=88324f81_39b3_4c32_894e_222387920a1f.ipynb','None')">Try it in your browser!</button></div>

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

```pycon
>>> idx = pd.Index(list("abcd"))
>>> idx.slice_indexer(start="b", end="c")
slice(1, 3, None)
```

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

<div id="12436481-200e-49af-9ace-5f4ede4b7856" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('16e68854-36f8-4fef-96a9-b49398ae71d0','12436481-200e-49af-9ace-5f4ede4b7856')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('16e68854-36f8-4fef-96a9-b49398ae71d0','12436481-200e-49af-9ace-5f4ede4b7856')">Open In Tab</button></div><div id="2ec83c05-0d83-4e17-9872-51f1cdf99efd" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
