Implementations of window operations such as rolling and expanding.
pip install window-opsWindow ops
This library is intended to be used as an alternative to
pd.Series.rolling and pd.Series.expanding to gain a speedup by using
numba optimized functions operating on numpy arrays. There are also
online classes for more efficient updates of window statistics.
Install
pip install window-ops
How to use
Transformations
For a transformations n_samples -> n_samples you can use
[seasonal_](rolling|expanding)_(mean|max|min|std) on an array.
Benchmarks
pd.__version__
'1.3.5'
n_samples = 10_000 # array size
window_size = 8 # for rolling operations
season_length = 7 # for seasonal operations
execute_times = 10 # number of times each function will be executed
Average times in milliseconds.
times.applymap('{:.2f}'.format)
| window_ops | pandas | |
|---|---|---|
| rolling_mean | 0.03 | 0.43 |
| rolling_max | 0.14 | 0.57 |
| rolling_min | 0.14 | 0.58 |
| rolling_std | 0.06 | 0.54 |
| expanding_mean | 0.03 | 0.31 |
| expanding_max | 0.05 | 0.76 |
| expanding_min | 0.05 | 0.47 |
| expanding_std | 0.09 | 0.41 |
| seasonal_rolling_mean | 0.05 | 3.89 |
| seasonal_rolling_max | 0.18 | 4.27 |
| seasonal_rolling_min | 0.18 | 3.75 |
| seasonal_rolling_std | 0.08 | 4.38 |
| seasonal_expanding_mean | 0.04 | 3.18 |
| seasonal_expanding_max | 0.06 | 3.29 |
| seasonal_expanding_min | 0.06 | 3.28 |
| seasonal_expanding_std |