# xarray.CFTimeIndex.to_numpy

#### CFTimeIndex.to_numpy(dtype=None, copy=False, na_value=<no_default>, \*\*kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.15/site-packages/pandas/core/base.py#L601-L752)

A NumPy ndarray representing the values in this Series or Index.

This method converts the underlying data to a NumPy array, optionally
specifying the desired dtype and handling of missing values. For
extension types, this may require copying data and coercing to a NumPy
type.

* **Parameters:**
  * **dtype** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`numpy.dtype`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html#numpy.dtype), *optional*) – The dtype to pass to `numpy.asarray()`.
  * **copy** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *default* [`False`](https://docs.python.org/3/builtins/constants.html#False)) – Whether to ensure that the returned value is not a view on
    another array. Note that `copy=False` does not *ensure* that
    `to_numpy()` is no-copy. Rather, `copy=True` ensure that
    a copy is made, even if not strictly necessary.
  * **na_value** (`Any`, *optional*) – The value to use for missing values. The default value depends
    on dtype and the type of the array.
  * **\*\*kwargs** – Additional keywords passed through to the `to_numpy` method
    of the underlying array (for extension arrays).
* **Returns:**
  [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) – The NumPy ndarray holding the values from this Series or Index.
  The dtype of the array may differ. See Notes.

#### SEE ALSO
`Series.array`
: Get the actual data stored within.

`Index.array`
: Get the actual data stored within.

`DataFrame.to_numpy`
: Similar method for DataFrame.

### Notes

The returned array will be the same up to equality (values equal
in self will be equal in the returned array; likewise for values
that are not equal). When self contains an ExtensionArray, the
dtype may be different. For example, for a category-dtype Series,
`to_numpy()` will return a NumPy array and the categorical dtype
will be lost.

For NumPy dtypes, this will be a reference to the actual data stored
in this Series or Index (assuming `copy=False`). Modifying the result
in place will modify the data stored in the Series or Index (not that
we recommend doing that).

For extension types, `to_numpy()` *may* require copying data and
coercing the result to a NumPy type (possibly object), which may be
expensive. When you need a no-copy reference to the underlying data,
`Series.array` should be used instead.

This table lays out the different dtypes and default return types of
`to_numpy()` for various dtypes within pandas.

| dtype              | array type                       |
|--------------------|----------------------------------|
| category[T]        | ndarray[T] (same dtype as input) |
| period             | ndarray[object] (Periods)        |
| interval           | ndarray[object] (Intervals)      |
| IntegerNA          | ndarray[object]                  |
| datetime64[ns]     | datetime64[ns]                   |
| datetime64[ns, tz] | ndarray[object] (Timestamps)     |

For timezone-aware datetime data, calling `to_numpy()` without
specifying `dtype` produces an object-dtype array of
`Timestamp` objects. This is significantly slower and uses
more memory than a native `datetime64` array. To avoid this,
pass an explicit `dtype`:

- `dtype="datetime64[ns]"` converts to UTC and drops the
  timezone, returning a native `datetime64[ns]` array.
- `dtype=object` explicitly requests Timestamp objects when
  you need to preserve per-element timezone information.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('0f3f7e1d-dbd2-455e-a6cf-2d93eed516ec','e8e6cc26-ae36-4fc0-8f4e-a615ba5f9735','44ce5299-0b68-4d7f-8665-c52b3e222d5e','../lite/tree/../notebooks/index.html?path=bf01752b_a6da_4e56_80dc_27d804287c73.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> ser = pd.Series(pd.Categorical(["a", "b", "a"]))
>>> ser.to_numpy()
array(['a', 'b', 'a'], dtype=object)
```

Specify the dtype to control how datetime-aware data is represented.
Use `dtype=object` to return an ndarray of pandas `Timestamp`
objects, each with the correct `tz`.

```pycon
>>> ser = pd.Series(pd.date_range("2000", periods=2, tz="CET"))
>>> ser.to_numpy(dtype=object)
array([Timestamp('2000-01-01 00:00:00+0100', tz='CET'),
       Timestamp('2000-01-02 00:00:00+0100', tz='CET')],
      dtype=object)
```

Or `dtype='datetime64[ns]'` to return an ndarray of native
datetime64 values. The values are converted to UTC and the timezone
info is dropped.

```pycon
>>> ser.to_numpy(dtype="datetime64[ns]")
...
array(['1999-12-31T23:00:00.000000000', '2000-01-01T23:00:00...'],
      dtype='datetime64[ns]')
```

<div id="44ce5299-0b68-4d7f-8665-c52b3e222d5e" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('0f3f7e1d-dbd2-455e-a6cf-2d93eed516ec','44ce5299-0b68-4d7f-8665-c52b3e222d5e')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('0f3f7e1d-dbd2-455e-a6cf-2d93eed516ec','44ce5299-0b68-4d7f-8665-c52b3e222d5e')">Open In Tab</button></div><div id="e8e6cc26-ae36-4fc0-8f4e-a615ba5f9735" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
