I created a moving average using rolling on a dataframe using the following source code
ma = produksi.price.rolling(window=3).mean()
hasil = hasil.append(ma)
mape= abs((produksi.price-ma)/produksi.price)
[![enter image description here][1]][1]
but the results of the moving average are like this, the calculation is correct, but the position is not as expected
I want the result like this [![enter image description here][2]][2]
to calculate the error value in the prediction of the fourth data [1]: https://i.stack.imgur.com/d8FBf.png [2]: https://i.stack.imgur.com/CalcT.png