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.

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 reflectd 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