I use the following code to find MEAN by using For loop,
It displays value for MEAN(5) but, for MEAN(8) it throws an error message - IndexError: list assignment index out of range.
It seems the problem in FOR loop. Can anyone help to fix this issue.
It displays value for MEAN(5) but, for MEAN(8) it throws an error message - IndexError: list assignment index out of range.
It seems the problem in FOR loop. Can anyone help to fix this issue.
ndays = ([5, 8]) meanALL = [''] for i in range(len(ndays)): meanALL[i] = df.rolling(window=ndays[i]).Price.mean().groupby('Name').head(ndays[i]).dropna() print(meanALL[i]) #i=0