I need to calculate the monthly covariance from two columns which contains daily values.
Day | x | y |
---|---|---|
2010-01-01 | 0,02 | 0,05 |
2010-01-02 | 0,04 | -0,06 |
2010-01-03 | 0,90 | 0,02 |
..... | .. | .. |
2010-02-01 | 0,04 | 0,05 |
2010-02-02 | 0,88 | 0,09 |
..... | .. | .. |
2010-03-01 | 0,03 | 0,25 |
2010-03-02 | 0,28 | 0,19 |
The result should be one line each month with the estimated covariance.
I tried to resample it but it doesn´t work:
df.resample('M').cov()
Error:
AttributeError: 'DatetimeIndexResampler' object has no attribute 'cov'
I looked up already for solutions but I only found some codes without monthly evaluation. How I could calculate this??