dask_expr._rolling.Rolling.apply
dask_expr._rolling.Rolling.apply¶
- Rolling.apply(func, *args, **kwargs)[source]¶
Calculate the rolling custom aggregation function.
This docstring was copied from pandas.core.window.rolling.Rolling.apply.
Some inconsistencies with the Dask version may exist.
- Parameters
- funcfunction
Must produce a single value from an ndarray input if
raw=True
or a single value from a Series ifraw=False
. Can also accept a Numba JIT function withengine='numba'
specified.- rawbool, default False (Not supported in Dask)
False
: passes each row or column as a Series to the function.True
: the passed function will receive ndarray objects instead. If you are just applying a NumPy reduction function this will achieve much better performance.
- enginestr, default None (Not supported in Dask)
'cython'
: Runs rolling apply through C-extensions from cython.'numba'
: Runs rolling apply through JIT compiled code from numba. Only available whenraw
is set toTrue
.None
: Defaults to'cython'
or globally settingcompute.use_numba
- engine_kwargsdict, default None (Not supported in Dask)
For
'cython'
engine, there are no acceptedengine_kwargs
For
'numba'
engine, the engine can acceptnopython
,nogil
andparallel
dictionary keys. The values must either beTrue
orFalse
. The defaultengine_kwargs
for the'numba'
engine is{'nopython': True, 'nogil': False, 'parallel': False}
and will be applied to both thefunc
and theapply
rolling aggregation.
- argstuple, default None (Not supported in Dask)
Positional arguments to be passed into func.
- kwargsdict, default None (Not supported in Dask)
Keyword arguments to be passed into func.
- Returns
- Series or DataFrame
Return type is the same as the original object with
np.float64
dtype.
See also
pandas.Series.rolling
Calling rolling with Series data.
pandas.DataFrame.rolling
Calling rolling with DataFrames.
pandas.Series.apply
Aggregating apply for Series.
pandas.DataFrame.apply
Aggregating apply for DataFrame.
Examples
>>> ser = pd.Series([1, 6, 5, 4]) >>> ser.rolling(2).apply(lambda s: s.sum() - s.min()) 0 NaN 1 6.0 2 6.0 3 5.0 dtype: float64