rolling average df

df['pandas_SMA_3'] = df.iloc[:,1].rolling(window=3).mean()

Here is what the above code is Doing:
1. We’re creating a new column in our dataframe called ‘pandas_SMA_3’.
2. We’re using the .rolling() method on our dataframe’s second column, which is the ‘Close’ column.
3. We’re telling the .rolling() method that we want to calculate the 3-day SMA.
4. We’re using the .mean() method to calculate the mean of the last 3 days.
5. We’re assigning the result to our new column, ‘pandas_SMA_3’.