Is there a SciPy function or NumPy function or module for Python that calculates the running mean of a 1D array given a specific window?
With @Aikude's variables, I wrote one-liner.
import numpy as np mylist = [1, 2, 3, 4, 5, 6, 7] N = 3 mean = [np.mean(mylist[x:x+N]) for x in range(len(mylist)-N+1)] print(mean) >>> [2.0, 3.0, 4.0, 5.0, 6.0]