There is a comment by mab buried in one of the answers above which has this method. bottleneck
has move_mean
which is a simple moving average:
import numpy as np
import bottleneck as bn
a = np.arange(10) + np.random.random(10)
mva = bn.move_mean(a, window=2, min_count=1)
min_count
is a handy parameter that will basically take the moving average up to that point in your array. If you don't set min_count
, it will equal window
, and everything up to window
points will be nan
.