Rolling.
apply
Apply an arbitrary function to each rolling window.
Must produce a single value from an ndarray input if raw=True or a single value from a Series if raw=False. Can also accept a Numba JIT function with engine='numba' specified.
raw=True
raw=False
engine='numba'
Changed in version 1.0.0.
False : passes each row or column as a Series to the function.
False
True : the passed function will receive ndarray objects instead. If you are just applying a NumPy reduction function this will achieve much better performance.
True
'cython' : Runs rolling apply through C-extensions from cython.
'cython'
'numba' : Runs rolling apply through JIT compiled code from numba. Only available when raw is set to True.
'numba'
raw
None : Defaults to 'cython' or globally setting compute.use_numba
None
compute.use_numba
New in version 1.0.0.
For 'cython' engine, there are no accepted engine_kwargs
engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False} and will be applied to both the func and the apply rolling aggregation.
nopython
nogil
parallel
{'nopython': True, 'nogil': False, 'parallel': False}
func
Positional arguments to be passed into func.
Keyword arguments to be passed into func.
Return type is determined by the caller.
See also
pandas.Series.rolling
Calling object with Series data.
pandas.DataFrame.rolling
Calling object with DataFrame data.
pandas.Series.apply
Similar method for Series.
pandas.DataFrame.apply
Similar method for DataFrame.
Notes
See Numba engine for extended documentation and performance considerations for the Numba engine.