# xarray.CFTimeIndex.get_indexer

#### CFTimeIndex.get_indexer(target, method=None, limit=None, tolerance=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.14/site-packages/pandas/core/indexes/base.py#L3656-L3796)

Compute indexer and mask for new index given the current index.

The indexer should be then used as an input to ndarray.take to align the
current data to the new index.

* **Parameters:**
  * **target** ([`Index`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.html#pandas.Index)) – An iterable containing the values to be used for computing indexer.
  * **method** (`{None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}`, *optional*) –
    * default: exact matches only.
    * pad / ffill: find the PREVIOUS index value if no exact match.
    * backfill / bfill: use NEXT index value if no exact match
    * nearest: use the NEAREST index value if no exact match. Tied
      distances are broken by preferring the larger index value.
  * **limit** ([`int`](https://docs.python.org/3/builtins/functions.html#int), *optional*) – Maximum number of consecutive labels in `target` to match for
    inexact matches.
  * **tolerance** (**optional**) – Maximum distance between original and new labels for inexact
    matches. The values of the index at the matching locations must
    satisfy the equation `abs(index[indexer] - target) <= tolerance`.

    Tolerance may be a scalar value, which applies the same tolerance
    to all values, or list-like, which applies variable tolerance per
    element. List-like includes list, tuple, array, Series, and must be
    the same size as the index and its dtype must exactly match the
    index’s type.
* **Returns:**
  `np.ndarray[np.intp]` – Integers from 0 to n - 1 indicating that the index at these
  positions matches the corresponding target values. Missing values
  in the target are marked by -1.

#### SEE ALSO
`Index.get_indexer_for`
: Returns an indexer even when non-unique.

`Index.get_non_unique`
: Returns indexer and masks for new index given the current index.

### Notes

Returns -1 for unmatched values, for further explanation see the
example below.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('38b0e906-a213-44bf-865a-8a343191331a','7034e336-902f-4813-80e6-218640bfb7e8','22705b0a-0164-4bfd-8298-9a9542f31fed','../lite/tree/../notebooks/index.html?path=3480e486_f7bd_49f0_bcae_79adac698061.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> index = pd.Index(["c", "a", "b"])
>>> index.get_indexer(["a", "b", "x"])
array([ 1,  2, -1])
```

Notice that the return value is an array of locations in `index`
and `x` is marked by -1, as it is not in `index`.

<div id="22705b0a-0164-4bfd-8298-9a9542f31fed" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('38b0e906-a213-44bf-865a-8a343191331a','22705b0a-0164-4bfd-8298-9a9542f31fed')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('38b0e906-a213-44bf-865a-8a343191331a','22705b0a-0164-4bfd-8298-9a9542f31fed')">Open In Tab</button></div><div id="7034e336-902f-4813-80e6-218640bfb7e8" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
