title: Summing rows based on conditional in Pandas
body: <p>I'm trying to understand how to sum up a subset of rows based on 2 indices in Pandas.  The first index groups the rows and the second index will determine which rows to sum.  For a minimal example suppose I have the dataframe</p>
  
  <pre><code>index1 | index2 | value
  ------------------------
    a    |    1   |  10
    a    |    2   |  11
    a    |    3   |  12
    b    |    1   |  20
    b    |    2   |  21
    b    |    3   |  22
  </code></pre>
  
  <p><strong>How can I sum the rows corresponding to index <code>1</code> and <code>2</code> but still have them grouped under index <code>a</code> and <code>b</code>.  I.e the following results.</strong></p>
  
  <pre><code>index1 | index2 | value
  ------------------------
    a    |    1   |  21
    a    |    2   |  12
    b    |    1   |  41
    b    |    2   |  22
  </code></pre>
  
  <p>Here the rows corresponding to <code>index2</code> of <code>1</code> and <code>2</code> have been summed into the new <code>index2</code> of <code>1</code>.</p>