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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -