I have the following framework:
df1
index year week a b c
-10 2017 10 45 26 19
-9 2017 11 37 23 14
-8 2017 12 21 66 19
-7 2017 13 47 36 92
-6 2017 14 82 65 18
-5 2017 15 68 68 19
-4 2017 16 30 95 24
-3 2017 17 21 15 94
-2 2017 18 67 30 16
-1 2017 19 10 13 13
0 2017 20 26 22 18
1 2017 21 NaN NaN NaN
2 2017 22 NaN NaN NaN
3 2017 23 NaN NaN NaN
4 2017 24 NaN NaN NaN
...
53 2018 20 NaN NaN NaN
I need each empty cell to calculate the average of the previous nth values in the column and write that value to the cell. nequal to the number of indices from zero and above. For example, for the first empty cell in the column, aI have to calculate the average between the indices 0and -10. Then for the next cell between 1and -9etc. Also for columns a, band c. And the calculations always begin where index = 1.
, , a, b, c, . , week. , , week?
-, .
UPD. , index = 0 down 53.