# xarray.CFTimeIndex.values

#### *property* CFTimeIndex.values

Return an array representing the data in the Index.

#### WARNING
We recommend using `Index.array` or
`Index.to_numpy()`, depending on whether you need
a reference to the underlying data or a NumPy array.
The return type of `.values` depends on the dtype: it is a
[`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) for some dtypes (for example `int64`
or `float64`) and an
[`ExtensionArray`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.api.extensions.ExtensionArray.html#pandas.api.extensions.ExtensionArray) for others (for
example `interval`, `category`, or nullable `Int64`),
which makes it harder to write code that works across dtypes.
`Index.array` always returns the underlying array as an
[`ExtensionArray`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.api.extensions.ExtensionArray.html#pandas.api.extensions.ExtensionArray), and
`Index.to_numpy()` always returns a [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)
and accepts `dtype`, `copy`, and `na_value` arguments to
control the conversion.

#### Versionchanged
Changed in version 3.0.0: The returned array is read-only.

* **Returns:**
  **array** ([`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) or `ExtensionArray`)

#### SEE ALSO
`Index.array`
: Reference to the underlying data.

`Index.to_numpy`
: A NumPy array representing the underlying data.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('f13a4684-d752-4022-b2e9-604d05e3918d','6c7d3a42-556c-424b-b717-4cd269446e2b','4e786c46-9602-4d1e-9bdf-188f7fcb9c2b','../lite/tree/../notebooks/index.html?path=68d3daa0_0764_4e0d_8a06_b59a9ab143cc.ipynb','None')">Try it in your browser!</button></div>

For an [`Index`](xarray.Index.html.md#xarray.Index) backed by a NumPy dtype such as `int64`,
`.values` returns a [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray):

```pycon
>>> idx = pd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='int64')
>>> idx.values
array([1, 2, 3])
```

For an [`Index`](xarray.Index.html.md#xarray.Index) backed by an extension dtype such as
`interval`, `.values` returns an
[`ExtensionArray`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.api.extensions.ExtensionArray.html#pandas.api.extensions.ExtensionArray) instead, while
`Index.to_numpy()` always returns a [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray):

```pycon
>>> idx = pd.interval_range(start=0, end=5)
>>> idx.values
<IntervalArray>
[(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]]
Length: 5, dtype: interval[int64, right]
>>> idx.to_numpy()
array([Interval(0, 1, closed='right'), Interval(1, 2, closed='right'),
       Interval(2, 3, closed='right'), Interval(3, 4, closed='right'),
       Interval(4, 5, closed='right')], dtype=object)
```

<div id="4e786c46-9602-4d1e-9bdf-188f7fcb9c2b" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('f13a4684-d752-4022-b2e9-604d05e3918d','4e786c46-9602-4d1e-9bdf-188f7fcb9c2b')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('f13a4684-d752-4022-b2e9-604d05e3918d','4e786c46-9602-4d1e-9bdf-188f7fcb9c2b')">Open In Tab</button></div><div id="6c7d3a42-556c-424b-b717-4cd269446e2b" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
