import numpy as np a = np.arange(6).reshape(3,2) average = np.average(a)
import numpy as np def moving_average(x, w): return np.convolve(x, np.ones(w), 'valid') / w