On this page
pandas.core.window.expanding.Expanding.apply
- Expanding.apply(func, raw=False, engine=None, engine_kwargs=None, args=None, kwargs=None)[source]
-
Calculate the expanding custom aggregation function.
- Parameters
-
- func:function
-
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.Changed in version 1.0.0.
- raw:bool, default False
-
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.
- engine:str, default None
-
'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
New in version 1.0.0.
- engine_kwargs:dict, default None
-
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.New in version 1.0.0.
- args:tuple, default None
-
Positional arguments to be passed into func.
- kwargs:dict, default None
-
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.expanding
-
Calling expanding with Series data.
-
pandas.DataFrame.expanding
-
Calling expanding with DataFrames.
-
pandas.Series.apply
-
Aggregating apply for Series.
-
pandas.DataFrame.apply
-
Aggregating apply for DataFrame.
© 2008–2022, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.5.0/reference/api/pandas.core.window.expanding.Expanding.apply.html