title: Hierarhical Multi-index counts in Pandas
body: <p>Say I have a multi-index dataframe in Pandas, e.g:</p>
  
  <pre><code>                         A         B         C
  X      Y     Z                                
  bar   one    a   -0.007381 -0.365315 -0.024817
               b   -1.219794  0.370955 -0.795125
  baz   three  a    0.145578  1.428502 -0.408384
               b   -0.249321 -0.292967 -1.849202
        two    a   -0.249321 -0.292967 -1.849202
        four   a    0.211234 -0.967123  1.202234
  foo   one    b   -1.046479 -1.250595  0.781722
               a    1.314373  0.333150  0.133331
  qux   one    c    0.716789  0.616471 -0.298493
        two    b    0.385795 -0.915417 -1.367644
  </code></pre>
  
  <p>How can I count how many levels are contained within another level? (e.g. level <code>Y</code> within <code>X</code>)</p>
  
  <p>E.g. in the case above the answer would be:</p>
  
  <pre><code>X    Y 
  bar  1
  baz  3
  foo  1
  qux  2
  </code></pre>
  
  <h1>Update</h1>
  
  <p>When I try <code>df.groupby(level=[0, 1]).count()[0]</code> I get:</p>
  
  <pre><code>            C  D  E
  A    B             
  bar  one    1  1  1
       three  1  1  1
  flux six    1  1  1
       three  1  1  1
  foo  five   1  1  1
       one    1  1  1
       two    2  2  2
  </code></pre>