# 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('d0ec01fe-4b2c-41f8-b05f-6f938c4df2b3','dfa1a801-6390-4580-90a1-de3f100c529f','2ce9957e-bf10-476b-9179-9f18684b4ee5','../lite/tree/../notebooks/index.html?path=5d187c18_2d6d_4288_9972_601b3a4e58c4.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="2ce9957e-bf10-476b-9179-9f18684b4ee5" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('d0ec01fe-4b2c-41f8-b05f-6f938c4df2b3','2ce9957e-bf10-476b-9179-9f18684b4ee5')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('d0ec01fe-4b2c-41f8-b05f-6f938c4df2b3','2ce9957e-bf10-476b-9179-9f18684b4ee5')">Open In Tab</button></div><div id="dfa1a801-6390-4580-90a1-de3f100c529f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
