- API reference
- Series
- pandas.Series.view
pandas.Series.view#
- Series.view(dtype=None)[source]#
Create a new view of the Series.
Deprecated since version 2.2.0:
Series.viewis deprecated and will be removed in a future version.UseSeries.astype()as an alternative to change the dtype.This function will return a new Series with a view of the sameunderlying values in memory, optionally reinterpreted with a new datatype. The new data type must preserve the same size in bytes as to notcause index misalignment.
- Parameters:
- dtypedata type
Data type object or one of their string representations.
- Returns:
- Series
A new Series object as a view of the same data in memory.
See also
numpy.ndarray.viewEquivalent numpy function to create a new view of the same data in memory.
Notes
Series are instantiated with
dtype=float64by default. Whilenumpy.ndarray.view()will return a view with the same data type asthe original array,Series.view()(without specified dtype)will try usingfloat64and may fail if the original data type sizein bytes is not the same.Examples
Use
astypeto change the dtype instead.