title: how to sum across many columns with pandas groupby?
body: <p>I have a dataframe that looks like</p>
  
  <pre><code>day  type  col  d_1  d_2  d_3  d_4  d_5...
  1    A     1    1    0    1    0
  1    A     2    1    0    1    0
  2    B     1    1    1    0    0
  </code></pre>
  
  <p>That is, I have one normal column (col) and many columns prefixed by d_</p>
  
  <p>I need to perform a groupby by day and type and I want to compute the sum of the values in every d_ column for every day-type combination. I also need to perform other aggregation functions on the other columns in my data (such as <code>col</code> in the example)</p>
  
  <p>I can use:</p>
  
  <pre><code>agg_df=df.groupby(['day','type']).agg({'d_1': 'sum', 'col': 'mean'})
  </code></pre>
  
  <p>but this computes the sum only for one d_ column. How can I specify all the possible d_ columns in my data? </p>
  
  <p>In other words, I would like to write something like</p>
  
  <pre><code>agg_df=df.groupby(['day','type']).agg({'d_*': 'sum', 'col': 'mean'})
  </code></pre>
  
  <p>so that the expected output is:</p>
  
  <pre><code>day  type  col  d_1  d_2  d_3  d_4  d_5...
  1    A     1.5  2    0    2    0    ...
  2    B     1    1    1    0    0
  </code></pre>
  
  <p>As you can see, col is aggregated by mean, while the d_ columns are summed.</p>
  
  <p>Thanks for your help!</p>