cudf.core.window.rolling.Rolling.apply#

Rolling.apply(func, *args, **kwargs)#

Counterpart of pandas.core.window.Rolling.apply.

Parameters
funcfunction

A user defined function that takes an 1D array as input

argstuple

unsupported.

kwargs

unsupported

See also

cudf.Series.applymap

Apply an elementwise function to transform the values in the Column.

Notes

See notes of the cudf.Series.applymap()

Examples

>>> import cudf
>>> def count_if_gt_3(window):
...     count = 0
...     for i in window:
...             if i > 3:
...                     count += 1
...     return count
...
>>> s = cudf.Series([0, 1.1, 5.8, 3.1, 6.2, 2.0, 1.5])
>>> s.rolling(3, min_periods=1).apply(count_if_gt_3)
0    0
1    0
2    1
3    2
4    3
5    2
6    1
dtype: int64