# xarray.CFTimeIndex.astype

#### CFTimeIndex.astype(dtype, copy=True)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.14/site-packages/pandas/core/indexes/base.py#L1111-L1180)

Create an Index with values cast to dtypes.

The class of a new Index is determined by dtype. When conversion is
impossible, a TypeError exception is raised.

* **Parameters:**
  * **dtype** (`numpy dtype` or `pandas type`) – Note that any signed integer dtype is treated as `'int64'`,
    and any unsigned integer dtype is treated as `'uint64'`,
    regardless of the size.
  * **copy** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *default* [`True`](https://docs.python.org/3/builtins/constants.html#True)) – By default, astype always returns a newly allocated object.
    If copy is set to False and internal requirements on dtype are
    satisfied, the original data is used to create a new Index
    or the original Index is returned.
* **Returns:**
  [`Index`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.html#pandas.Index) – Index with values cast to specified dtype.

#### SEE ALSO
`Index.dtype`
: Return the dtype object of the underlying data.

`Index.dtypes`
: Return the dtype object of the underlying data.

`Index.convert_dtypes`
: Convert columns to the best possible dtypes.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('275411ac-2043-47a3-84e6-cfd845dc524e','ddd7e60d-b8aa-493f-9a14-a393e7de93b2','2336bf42-aec7-4192-bf94-227b473a5e14','../lite/tree/../notebooks/index.html?path=fad5e868_7359_4b33_b6ce_85faf1c3a1ae.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> idx = pd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='int64')
>>> idx.astype("float")
Index([1.0, 2.0, 3.0], dtype='float64')
```

<div id="2336bf42-aec7-4192-bf94-227b473a5e14" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('275411ac-2043-47a3-84e6-cfd845dc524e','2336bf42-aec7-4192-bf94-227b473a5e14')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('275411ac-2043-47a3-84e6-cfd845dc524e','2336bf42-aec7-4192-bf94-227b473a5e14')">Open In Tab</button></div><div id="ddd7e60d-b8aa-493f-9a14-a393e7de93b2" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
