python calculate moving average code example
Example 1: rolling average df
df['pandas_SMA_3'] = df.iloc[:,1].rolling(window=3).mean()
Example 2: moving averages python
df['data'].rolling(3).mean()
df['data'].shift(periods=1).rolling(3).mean()
df['pandas_SMA_3'] = df.iloc[:,1].rolling(window=3).mean()
df['data'].rolling(3).mean()
df['data'].shift(periods=1).rolling(3).mean()