python如何做滑动平均

def moving_average(interval, windowsize):
    window = np.ones(int(windowsize)) / float(windowsize)
    re = np.convolve(interval, window, 'same')
    return re

#寻找峰谷,并进行标记;
sig = bodyPart4['dis'].to_numpy()

sigAv = moving_average(sig, 3)#做一下简单的滑动平均
plt.plot(sigAv, 'g')
np.savetxt(r"D:\PythonProject\QTNLS\resources\t7\hand-dis-ave.csv", sigAv, delimiter=",")

你可能感兴趣的:(python)