title: How to calculate np.cov on a matrix with np.nan values without converting to pd.DataFrame?
body: <p>I have the following <code>np.array</code>:</p>
  
  <pre><code>my_matrix = np.array([[1,np.nan,3], [np.nan,1,2], [np.nan,1,2]])
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>array([[ 1., nan,  3.],
         [nan,  1.,  2.],
         [nan,  1.,  2.]])
  </code></pre>
  
  <p>If I evaluate <code>np.cov</code> on it, I get:</p>
  
  <pre><code>np.cov(my_matrix)
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>array([[nan, nan, nan],
         [nan, nan, nan],
         [nan, nan, nan]])
  </code></pre>
  
  <p>But if I were to calculate it with <code>pd.DataFrame.cov</code> I get a different result:</p>
  
  <pre><code>pd.DataFrame(my_matrix).cov()
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>    0   1   2
  0   NaN NaN NaN
  1   NaN 0.0 0.000000
  2   NaN 0.0 0.333333
  </code></pre>
  
  <p>I know that as per <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.cov.html" rel="nofollow noreferrer"><code>pandas</code></a> documentation, they handle <code>nan</code> values.</p>
  
  <p>My question is, how can I get the same (or similar result) with <code>numpy</code>? Or how to handle missing data when calculating covariance with <code>numpy</code>?</p>