0

I am handling finanical trading data, i want to calculate the future 10 days price's mean/std value.

but when i call rolling method, it comes out error: window must be non-negative.

import pandas as pd
a=pd.Series([1,2,9, 3,8,12,15])
a.rolling(2).mean()   # this is ok
a.rolling(-2).mean()  # this failed, as window cant be non-negative, but i want to calculate the future 2 window's mean, i think it's a common operation, why it failed?
# i want to calcualte the future 2 windows's mean, for example, the first output should be 5.5, as the future 2 window is [2,9]

I think for diff, shift method, the window_size can be non-negetive, why rolling cant?

Is there any method that i can implement this function?

xyhuang
  • 414
  • 3
  • 11

0 Answers0