title: Compute Covariance Matrix Manually (without Numpy np.cov)
body: <p>I'm new to Python and am trying to compute the covariance matrix for a 3x3 matrix manually. Below is my code:</p>
  <pre><code>df = np.array([[1,2,3],[4,5,6],[7,8,9]]) # example 3x3 matrix
  means = df.mean
  cov = []
  for j in range(len(means)):
      sum = 0
      covs = []
      for k in range(len(means)):
          terms = ( (df[i][j] - means[j]) * (df[i][k] - means[k]) for i in range(len(means)) )
          covariance  = sum(terms) / len(means)
          covs.append(covariance)
  </code></pre>
  <p>I'm getting the following error:</p>
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-83-3e38715077d0&gt; in &lt;module&gt;
        1 means = df.mean
        2 Cov = []
  ----&gt; 3 for j in range(len(means)):
        4     sum = 0
        5     covs = []
  
  TypeError: object of type 'method' has no len()
  </code></pre>
  <p>EDIT: I just updated to df.mean() per the suggestion, but now I receive the following error:</p>
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-103-9d6e2f3103c9&gt; in &lt;module&gt;
        6     for k in range(len(means)):
        7         terms = ( (df[i][j] - means[j]) * (df[i][k] - means[k]) for i in range(len(means)) )
  ----&gt; 8         covariance  = sum(terms) / len(means)
        9         covs.append(covariance)
  
  TypeError: 'int' object is not callable
  </code></pre>
  <p>Would appreciate any help/explanation for how to fix my calculation! Thanks</p>