Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Create covariance matrix on columns that are not full

$
0
0

I'm looking to create a variance/covariance matrix or a correlation matrix (I don't care which) on stock data.

The issue is that different symbols trade at different times, so my dataframe is not full.

How would I generate a covariance matrix on a dataset that has a timestamp column, and where some entries are null.

Here would be an example.

            timestamp   usdjpy  AAPL  NIKKEI0 2021-01-01 00:00:00        4   NaN     NaN1 2021-01-01 00:05:00        5     5     NaN2 2021-01-01 00:10:00        6     6       93 2021-01-01 00:15:00        4     2       44 2021-01-01 00:20:00        2   NaN       35 2021-01-01 00:25:00        7   NaN       7

What I would want here is the covariance between usdjpy and aapl to be computed on their overlapping timestamps.


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>