title: How can I "merge" rows by same value in a column in Pandas with aggregation functions?
body: <p>I would like to group rows in a dataframe, given one column. Then I would like to receive an edited dataframe for which I can decide which aggregation function makes sense. The default should be just the value of the first entry in the group.</p>
  
  <p>(it would be nice if the solution also worked for a combination of two columns)</p>
  
  <h2>Example</h2>
  
  <pre><code>#!/usr/bin/env python
  
  """Test data frame grouping."""
  
  # 3rd party modules
  import pandas as pd
  
  
  df = pd.DataFrame([{'id': 1, 'price': 123, 'name': 'anna', 'amount': 1},
                     {'id': 1, 'price':   7, 'name': 'anna', 'amount': 2},
                     {'id': 2, 'price':  42, 'name': 'bob', 'amount': 30},
                     {'id': 3, 'price':   1, 'name': 'charlie', 'amount': 10},
                     {'id': 3, 'price':   2, 'name': 'david', 'amount': 100}])
  print(df)
  </code></pre>
  
  <p>gives the dataframe:</p>
  
  <pre><code>   amount  id     name  price
  0       1   1     anna    123
  1       2   1     anna      7
  2      30   2      bob     42
  3      10   3  charlie      1
  4     100   3    david      2
  </code></pre>
  
  <p>And I would like to get:</p>
  
  <pre><code>amount  id     name  price
       3   1     anna    130
      30   2      bob     42
     110   3  charlie      3
  </code></pre>
  
  <p>So:</p>
  
  <ul>
  <li>Entries with the same value in the <code>id</code> column belong together. After that operation, there should still be an <code>id</code> column, but it should have only unique values.</li>
  <li>All values in <code>amount</code> and <code>price</code> which have the same <code>id</code> get summed up</li>
  <li>For <code>name</code>, just the first one (by the current order of the dataframe) is taken.</li>
  </ul>
  
  <p>Is this possible with Pandas?</p>