You are viewing documentation about an older version (1.18.0). View latest version

modin.pandas.Series.shift¶

Series.shift(periods: int | Sequence[int] = 1, freq=None, axis: Axis = 0, fill_value: Hashable = _NoDefault.no_default, suffix: str | None = None)[source]¶

Shift data by desired number of periods and replace columns with fill_value (default: None).

Snowpark pandas does not support freq currently.

The axis parameter is unused, and defaults to 0.

Parameters:
  • periods (int) – Number of periods to shift. Can be positive or negative.

  • freq (not supported, default None) –

  • axis ({0 or 'index', 1 or 'columns', None}, default None) – Shift direction. This parameter is unused and expects 0, ‘index’ or None.

  • fill_value (object, optional) – The scalar value to use for newly introduced missing values. the default depends on the dtype of self. For numeric data, np.nan is used. For datetime, timedelta, or period data, etc. NaT is used. For extension dtypes, self.dtype.na_value is used.

Returns:

Copy of input object, shifted.

Return type:

Series

Examples

>>> s = pd.Series([10, 20, 15, 30, 45],
...                   index=pd.date_range("2020-01-01", "2020-01-05"))
>>> s
2020-01-01    10
2020-01-02    20
2020-01-03    15
2020-01-04    30
2020-01-05    45
Freq: None, dtype: int64
Copy
>>> s.shift(periods=3)
2020-01-01     NaN
2020-01-02     NaN
2020-01-03     NaN
2020-01-04    10.0
2020-01-05    20.0
Freq: None, dtype: float64
Copy
>>> s.shift(periods=-2)
2020-01-01    15.0
2020-01-02    30.0
2020-01-03    45.0
2020-01-04     NaN
2020-01-05     NaN
Freq: None, dtype: float64
Copy
>>> s.shift(periods=3, fill_value=0)
2020-01-01     0
2020-01-02     0
2020-01-03     0
2020-01-04    10
2020-01-05    20
Freq: None, dtype: int64
Copy