pandas.api.extensions.ExtensionArray.view#

ExtensionArray.view(dtype=None)[source]#

Return a view on the array.

Parameters:
dtypestr, np.dtype, or ExtensionDtype, optional

Default None.

Returns:
ExtensionArray or np.ndarray

A view on the ExtensionArray’s data.

See also

api.extensions.ExtensionArray.ravel

Return a flattened view on input array.

Index.view

Equivalent function for Index.

ndarray.view

New view of array with the same data.

Examples

This gives view on the underlying data of an ExtensionArray and is not a copy. Modifications on either the view or the original ExtensionArray will be reflected on the underlying data:

>>> arr = pd.array([1, 2, 3])
>>> arr2 = arr.view()
>>> arr[0] = 2
>>> arr2
<IntegerArray>
[2, 2, 3]
Length: 3, dtype: Int64