title: Pandas: How to group by and sum MultiIndex
body: <p>I have a dataframe with categorical attributes where the index contains duplicates. I am trying to find the sum of each possible combination of index and attribute.   </p>
  
  <pre><code>x = pd.DataFrame({'x':[1,1,3,3],'y':[3,3,5,5]},index=[11,11,12,12])
  y = x.stack()
  print(y)
  print(y.groupby(level=[0,1]).sum())
  </code></pre>
  
  <p>output</p>
  
  <pre><code>11  x    1
      y    3
      x    1
      y    3
  12  x    3
      y    5
      x    3
      y    5
  dtype: int64
  11  x    1
      y    3
      x    1
      y    3
  12  x    3
      y    5
      x    3
      y    5
  dtype: int64
  </code></pre>
  
  <p>The stack and group by sum are just the same.</p>
  
  <p>However, the one I expect is</p>
  
  <pre><code>11  x    2
  11  y    6
  12  x    6
  12  y    10
  </code></pre>
  
  <p>EDIT 2:</p>
  
  <pre><code>x = pd.DataFrame({'x':[1,1,3,3],'y':[3,3,5,5]},index=[11,11,12,12])
  y = x.stack().groupby(level=[0,1]).sum()
  print(y.groupby(level=[0,1]).sum())
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>11  x    1
      y    3
      x    1
      y    3
  12  x    3
      y    5
      x    3
      y    5
  dtype: int64
  </code></pre>
  
  <p>EDIT3:
  An issue has been logged
  <a href="https://github.com/pydata/pandas/issues/10417" rel="nofollow">https://github.com/pydata/pandas/issues/10417</a></p>