- Rolling.apply(func, *args, **kwargs)#
Calculate the rolling custom aggregation function.
A user defined function that takes an 1D array as input
Apply an elementwise function to transform the values in the Column.
The supported Python features are listed in
with these exceptions:
Math functions in cmath are not supported since libcudf does not have complex number support and output of cmath functions are most likely complex numbers.
These five functions in math are not supported since numba generates multiple PTX functions from them:
Series with string dtypes are not supported.
Global variables need to be re-defined explicitly inside the udf, as numba considers them to be compile-time constants and there is no known way to obtain value of the global variable.
>>> 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