A generic wrapper for performing rolling computations.
This can be wrapped around any object which implements both an
update and a
revert method. Inputs to
update are stored in a queue. Elements of the queue are popped when the window is full.
An object that implements both an
updatemethod and a
Size of the window.
For instance, here is how you can compute a rolling average over a window of size 3:
>>> from river import stats, utils >>> X = [1, 3, 5, 7] >>> rmean = utils.Rolling(stats.Mean(), window_size=3) >>> for x in X: ... print(rmean.update(x).get()) 1.0 2.0 3.0 5.0