I would like to know if there is a specific function in Python for calculating moving averages. In MATLAB there is one called "tsmovavg" that has an algorithm called "Financial Time Series". Will the same algorithm exist in Python?
I would like to know if there is a specific function in Python for calculating moving averages. In MATLAB there is one called "tsmovavg" that has an algorithm called "Financial Time Series". Will the same algorithm exist in Python?
list = [1, 2, 3, 4, 5, 6, 7]
N = 3
cumsum, moving_averages = [0], []
for i, x in enumerate(list, 1):
cumsum.append(cumsum[i-1] + x)
if i>=N:
moving_ave = (cumsum[i] - cumsum[i-N])/N
#Puedes hacer cosas con el promedio movil aquí
moving_averages.append(moving_ave)