rolling average df
df['pandas_SMA_3'] = df.iloc[:,1].rolling(window=3).mean()
rolling average df
df['pandas_SMA_3'] = df.iloc[:,1].rolling(window=3).mean()
python moving average of list
import numpy
def running_mean(x, N):
""" x == an array of data. N == number of samples per average """
cumsum = numpy.cumsum(numpy.insert(x, 0, 0))
return (cumsum[N:] - cumsum[:-N]) / float(N)
val = [-30.45, -2.65, 56.61, 47.13, 47.95, 30.45, 2.65, -28.31, -47.13, -95.89]
print(running_mean(val, 3))
""" [ 7.83666667 33.69666667 50.56333333 41.84333333 27.01666667
1.59666667 -24.26333333 -57.11 ] """
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us