Pandas: How to calculate the average with rolling() but without including the last row?

Viewed 17

I am a beginner. I have to calculate the average prices for a window of 10 but when using rolling() the calculation also includes the last price. I need you to calculate the average without the last price. I tried to delete with drop() but I get the following error. "AttributeError: 'numpy.float64' object has no attribute 'drop' "

avg = self.prices.rolling(window=10).mean()

avg = avg.iloc[-1].drop()

I don't know how else you can get what I'm trying to calculate

0 Answers
Related