# xarray.CFTimeIndex.view

#### CFTimeIndex.view(cls=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.14/site-packages/pandas/core/indexes/base.py#L1033-L1109)

Return a view of the Index with the specified dtype or a new Index instance.

This method returns a view of the calling Index object if no arguments are
provided. If a dtype is specified through the cls argument, it attempts
to return a view of the Index with the specified dtype. Note that viewing
the Index as a different dtype reinterprets the underlying data, which can
lead to unexpected results for non-numeric or incompatible dtype conversions.

* **Parameters:**
  **cls** (`data-type` or `ndarray sub-class`, *optional*) – Data-type descriptor of the returned view, e.g., float32 or int16.
  Omitting it results in the view having the same data-type as self.
  This argument can also be specified as an ndarray sub-class,
  e.g., np.int64 or np.float32 which then specifies the type of
  the returned object.
* **Returns:**
  [`Index`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.html#pandas.Index) or [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) – A view of the Index. If cls is None, the returned object is an Index
  view with the same dtype as the calling object. If a numeric cls is
  specified an ndarray view with the new dtype is returned.
* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If attempting to change to a dtype in a way that is not compatible with
      the original dtype’s memory layout, for example, viewing an ‘int64’ Index
      as ‘str’.

#### SEE ALSO
[`Index.copy`](xarray.Index.copy.html.md#xarray.Index.copy)
: Returns a copy of the Index.

[`numpy.ndarray.view`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.view.html#numpy.ndarray.view)
: Returns a new view of array with the same data.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('9525bbab-3991-42a7-a9a2-5f546c605113','5bb98cdf-e72e-41c2-8a12-1ed0dc46bc30','8e99c91d-4106-456e-b560-dba9a66b93e4','../lite/tree/../notebooks/index.html?path=e6e2f888_f945_4fa6_8189_128bbf9ddc46.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> idx = pd.Index([-1, 0, 1])
>>> idx.view()
Index([-1, 0, 1], dtype='int64')
```

```pycon
>>> idx.view(np.uint64)
array([18446744073709551615,                    0,                    1],
  dtype=uint64)
```

Viewing as ‘int32’ or ‘float32’ reinterprets the memory, which may lead to
unexpected behavior:

```pycon
>>> idx.view("float32")
array([   nan,    nan, 0.e+00, 0.e+00, 1.e-45, 0.e+00], dtype=float32)
```

<div id="8e99c91d-4106-456e-b560-dba9a66b93e4" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('9525bbab-3991-42a7-a9a2-5f546c605113','8e99c91d-4106-456e-b560-dba9a66b93e4')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('9525bbab-3991-42a7-a9a2-5f546c605113','8e99c91d-4106-456e-b560-dba9a66b93e4')">Open In Tab</button></div><div id="5bb98cdf-e72e-41c2-8a12-1ed0dc46bc30" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
