pandas.api.extensions.ExtensionArray.shift¶
-
ExtensionArray.
shift
(self, periods: int = 1, fill_value: object = None) → pandas.core.dtypes.generic.ABCExtensionArray[source]¶ Shift values by desired number.
Newly introduced missing values are filled with
self.dtype.na_value
.New in version 0.24.0.
Parameters: - periods : int, default 1
The number of periods to shift. Negative values are allowed for shifting backwards.
- fill_value : object, optional
The scalar value to use for newly introduced missing values. The default is
self.dtype.na_value
New in version 0.24.0.
Returns: - shifted : ExtensionArray
Notes
If
self
is empty orperiods
is 0, a copy ofself
is returned.If
periods > len(self)
, then an array of size len(self) is returned, with all values filled withself.dtype.na_value
.