title: pandas, apply multiple functions of multiple columns to groupby object
body: <p>I want to apply multiple functions of multiple columns to a groupby object which results in a new <code>pandas.DataFrame</code>.</p>
  
  <p>I know how to do it in seperate steps:</p>
  
  <pre><code>by_user = lasts.groupby('user')
  elapsed_days = by_user.apply(lambda x: (x.elapsed_time * x.num_cores).sum() / 86400)
  running_days = by_user.apply(lambda x: (x.running_time * x.num_cores).sum() / 86400)
  user_df = elapsed_days.to_frame('elapsed_days').join(running_days.to_frame('running_days'))
  </code></pre>
  
  <p>Which results in <code>user_df</code> being:
  <a href="https://i.stack.imgur.com/4Tqd7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4Tqd7.png" alt="user_df"></a></p>
  
  <p>However I suspect that there is a better way, like:</p>
  
  <pre><code>by_user.agg({'elapsed_days': lambda x: (x.elapsed_time * x.num_cores).sum() / 86400, 
               'running_days': lambda x: (x.running_time * x.num_cores).sum() / 86400})
  </code></pre>
  
  <p>However, this doesn't work, because AFAIK <code>agg()</code> works on <code>pandas.Series</code>.</p>
  
  <p>I did find <a href="https://stackoverflow.com/q/14529838/3447047">this question and answer</a>, but the solutions look rather ugly to me, and considering that the answer is nearly four years old, there might be a better way by now.</p>