1#Creating a 100 day moving average from 'Close Price' column
2df['Close Price'].rolling(100).mean()
1df['MA'] = df.rolling(window=5).mean()
2
3print(df)
4# Value MA
5# Date
6# 1989-01-02 6.11 NaN
7# 1989-01-03 6.08 NaN
8# 1989-01-04 6.11 NaN
9# 1989-01-05 6.15 NaN
10# 1989-01-09 6.25 6.14
11# 1989-01-10 6.24 6.17
12# 1989-01-11 6.26 6.20
13# 1989-01-12 6.23 6.23
14# 1989-01-13 6.28 6.25
15# 1989-01-16 6.31 6.27
16