title: Speedup selecting subset
body: <p>I'm trying to select subset of pandas dataframe and compute some statistics, but it's painfully slow, maybe it can be done faster?</p>
  
  <pre><code>column_name1_set = df.column_name1.unique()
  column_name2_set = df.column_name2.unique()
  
  for i, name1 in enumerate(column_name1_set):
      for name2 in column_name2_set:
          df_t = df[(df['column_name1']==int(name1)) &amp; (df['column_name2']==name2)]
          s = df_t.sum(axis=0)
          s['amount_min'] = df_t['amount'].min()
          s['amount_max'] = df_t['amount'].max()
          s['amount_mean'] = df_t['amount'].mean()
          s['amount_median'] = df_t['amount'].median()
  
          #store s ...
  </code></pre>