title: Python Pandas: covariance between 2 columns
body: <p>I've read few posts on the topic but none were totally satisfying - for me
  say I have a DF 'A'</p>
  
  <pre><code>CG2 CG1 X   Y   Z
  1   1   5   4   1    
  3   1   6   7   2    
  1   1   9   2   5   
  3   2   4   9   3    
  1   2   8   5   6    
  3   2   3   6   7
  </code></pre>
  
  <p>I am trying to bet a new DF 'B' with the covariances between X and Z by ['CG1','CG2']
  My best effort was</p>
  
  <pre><code>B= A.groupby(['CG1','C2'],as_index=True)[['X','Z']].cov()
  </code></pre>
  
  <p>DF 'B' is like (cov values are dummy :-):</p>
  
  <pre><code>index       X      Z
  
  (1,1,'X')  2.3     0
  
  ...
  </code></pre>
  
  <p>I was expecting more something like</p>
  
  <pre><code>CG1  CG2   X   Z
  
  1     1    2.3 0
  
  ...
  </code></pre>
  
  <p>any hints for me ?</p>
  
  <p>Cheers
  apologies for the poor presentation of the dummy data</p>