pandas - apply rolling custom function on a dataframe with multiple outputs -
i have following dataframe: mydf
date b c 1973-01-01 0.002 -0.003 0.004 1973-02-01 0.003 -0.005 0.006 ...
i have function takes dataframe, date field, type of covariance , returns average return, covariance matrix, , annualized covariance matrix
def myfunc(mydf, dtfield, typecov): #does computations based on type either equal weighted or exponentially weighted ... ... return eret, cov, cova
the call myfunc(mydf, 'date', 'e')
i trying use rolling function in pandas in order this, using 250 window, not sure how this.
it works when use loop
minwindow = 250
for in range(minwindow, minwindow+5): temp = mydf[i-minwindow:i] eret, c, ca = myfunc(temp,dtfield, typecov)
thanks
wiki
Comments
Post a Comment