# 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('2eceede3-8c27-496e-9843-d4e248471b12','6d14113b-7319-4c9a-a60f-3fc1a54996c1','b991d4fc-5d3d-4082-9704-650033ed6dbf','../lite/tree/../notebooks/index.html?path=50933666_4df4_4a74_a474_65fb12e9f01e.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="b991d4fc-5d3d-4082-9704-650033ed6dbf" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('2eceede3-8c27-496e-9843-d4e248471b12','b991d4fc-5d3d-4082-9704-650033ed6dbf')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('2eceede3-8c27-496e-9843-d4e248471b12','b991d4fc-5d3d-4082-9704-650033ed6dbf')">Open In Tab</button></div><div id="6d14113b-7319-4c9a-a60f-3fc1a54996c1" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
