# 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.14/site-packages/pandas/core/indexes/base.py#L6753-L6812)

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('d87be8ec-cb9b-43a9-97de-b0142142aa92','e6d76bde-4ba0-4f8d-b58b-c05849e1803c','d2fe199a-c2b8-4bcd-ab46-43721e192d24','../lite/tree/../notebooks/index.html?path=a01fd341_c069_4493_b215_c6595277ab9b.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="d2fe199a-c2b8-4bcd-ab46-43721e192d24" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('d87be8ec-cb9b-43a9-97de-b0142142aa92','d2fe199a-c2b8-4bcd-ab46-43721e192d24')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('d87be8ec-cb9b-43a9-97de-b0142142aa92','d2fe199a-c2b8-4bcd-ab46-43721e192d24')">Open In Tab</button></div><div id="e6d76bde-4ba0-4f8d-b58b-c05849e1803c" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
