bigframes.pandas.Series.rolling#
- Series.rolling(window: int | Timedelta | timedelta64 | timedelta | str, min_periods: int | None = None, closed: Literal['right', 'left', 'both', 'neither'] = 'right') Window[source]#
Provide rolling window calculations.
Examples:
>>> import bigframes.pandas as bpd >>> s = bpd.Series([0,1,2,3,4]) >>> s.rolling(window=3).min() 0 <NA> 1 <NA> 2 0 3 1 4 2 dtype: Int64
>>> df = bpd.DataFrame({'A': [0,1,2,3], 'B': [0,2,4,6]}) >>> df.rolling(window=2, on='A', closed='both').sum() A B 0 0 <NA> 1 1 2 2 2 6 3 3 12 [4 rows x 2 columns]
- Parameters:
window (int, pandas.Timedelta, numpy.timedelta64, datetime.timedelta, str) –
Size of the moving window.
If an integer, the fixed number of observations used for each window.
If a string, the timedelta representation in string. This string must be parsable by pandas.Timedelta().
Otherwise, the time range for each window.
min_periods (int, default None) –
Minimum number of observations in window required to have a value; otherwise, result is
np.nan.For a window that is specified by an integer,
min_periodswill default to the size of the window.For a window that is not spicified by an interger,
min_periodswill default to 1.on (str, optional) – For a DataFrame, a column label on which to calculate the rolling window, rather than the DataFrame’s index.
closed (str, default 'right') – If ‘right’, the first point in the window is excluded from calculations. If ‘left’, the last point in the window is excluded from calculations. If ‘both’, the no points in the window are excluded from calculations. If ‘neither’, the first and last points in the window are excluded from calculations.
- Returns:
Windowsubclass if awin_typeis passed.Rollingsubclass ifwin_typeis not passed.
- Return type:
bigframes.core.window.Window