# xarray.CFTimeIndex.isin

#### CFTimeIndex.isin(values, level=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.14/site-packages/pandas/core/indexes/base.py#L6675-L6746)

Return a boolean array where the index values are in values.

Compute boolean array of whether each index value is found in the
passed set of values. The length of the returned boolean array matches
the length of the index.

* **Parameters:**
  * **values** ([`set`](https://docs.python.org/3/builtins/stdtypes.html#set) or `list-like`) – Sought values.
  * **level** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`int`](https://docs.python.org/3/builtins/functions.html#int), *optional*) – Name or position of the index level to use (if the index is a
    MultiIndex).
* **Returns:**
  `np.ndarray[bool]` – NumPy array of boolean values.

#### SEE ALSO
`Series.isin`
: Same for Series.

`DataFrame.isin`
: Same method for DataFrames.

### Notes

In the case of MultiIndex you must either specify values as a
list-like object containing tuples that are the same length as the
number of levels, or specify level. Otherwise it will raise a
`ValueError`.

If level is specified:

- if it is the name of one *and only one* index level, use that level;
- otherwise it should be a number indicating level position.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('784c4665-a705-4f3b-8a12-ff453ab9c2f5','f219e3f3-d7e0-4fca-a9a3-6ec819d2866a','bc995ceb-f5ef-4ba0-9863-32be2a9478df','../lite/tree/../notebooks/index.html?path=21be4282_8ea1_43e9_870a_f0890acbcfc2.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> idx = pd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='int64')
```

Check whether each index value in a list of values.

```pycon
>>> idx.isin([1, 4])
array([ True, False, False])
```

```pycon
>>> midx = pd.MultiIndex.from_arrays(
...     [[1, 2, 3], ["red", "blue", "green"]], names=["number", "color"]
... )
>>> midx
MultiIndex([(1,   'red'),
            (2,  'blue'),
            (3, 'green')],
           names=['number', 'color'])
```

Check whether the strings in the ‘color’ level of the MultiIndex
are in a list of colors.

```pycon
>>> midx.isin(["red", "orange", "yellow"], level="color")
array([ True, False, False])
```

To check across the levels of a MultiIndex, pass a list of tuples:

```pycon
>>> midx.isin([(1, "red"), (3, "red")])
array([ True, False, False])
```

<div id="bc995ceb-f5ef-4ba0-9863-32be2a9478df" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('784c4665-a705-4f3b-8a12-ff453ab9c2f5','bc995ceb-f5ef-4ba0-9863-32be2a9478df')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('784c4665-a705-4f3b-8a12-ff453ab9c2f5','bc995ceb-f5ef-4ba0-9863-32be2a9478df')">Open In Tab</button></div><div id="f219e3f3-d7e0-4fca-a9a3-6ec819d2866a" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
