title: Groupby() and aggregation in pandas
body: <p>I have a <code>pd.DataFrame</code> that looks like this:</p>
  
  <pre><code>In [149]: df
  Out[149]: 
     AMOUNT       DATE  ORDER_ID  UID
  0    1001 2014-01-02       101    1
  1    1002 2014-01-03       102    3
  2    1003 2014-01-04       103    4
  3    1004 2014-01-05       104    5
  4    1005 2014-01-09       105    5
  5    1006 2014-01-07       106    7
  6    1007 2014-01-08       107    8
  7    1008 2014-01-09       108    5
  8    1009 2014-01-10       109   10
  9    1500 2014-01-09       110    5
  </code></pre>
  
  <p>and I want to truncate all rows that correspond to the same UID and DATE to one row and use the sum of the values in the <code>AMOUNT</code> column for the one row that remains.</p>
  
  <p>In short, the desired output would be:</p>
  
  <blockquote>
  <pre><code>In [149]: df
  Out[149]: 
     AMOUNT       DATE  ORDER_ID  UID
  0    1001 2014-01-02       101    1
  1    1002 2014-01-03       102    3
  2    1003 2014-01-04       103    4
  3    1004 2014-01-05       104    5
  4    3513 2014-01-09       105    5 ## &lt;- Rows that previously had index [7,9,4] are now truncated to this one row and the AMOUNT is the sum of of the AMOUNT values of those three rows
  5    1006 2014-01-07       106    7
  6    1007 2014-01-08       107    8
  8    1009 2014-01-10       109   10
  </code></pre>
  </blockquote>
  
  <p><strong>In essence, what I want to do is 'aggregate' all rows that correspond to the same user UID and DATE to one row and leave all other rows intact.</strong></p>
  
  <p>What I've tried so far is this:</p>
  
  <pre><code>In [154]: df.groupby(['UID','DATE'])['AMOUNT'].sum()
  Out[154]: 
  UID  DATE      
  1    2014-01-02    1001
  3    2014-01-03    1002
  4    2014-01-04    1003
  5    2014-01-05    1004
       2014-01-09    3513
  7    2014-01-07    1006
  8    2014-01-08    1007
  10   2014-01-10    1009
  Name: AMOUNT, dtype: int64
  </code></pre>
  
  <p><strong><em>but</em></strong> I'm not sure where to start in order to either go back to original <code>df</code> and remove the 'extra' rows nor how to assign the new sum value of <code>AMOUNT</code> to the one remaining row.</p>
  
  <p>Any help is very appreciated!</p>