title: Count of a column and sum of another in the same groupby?
body: <p>This dataframe:</p>
  
  <pre><code>df = pd.DataFrame({'delivery_date' : ['2018-09-07' ,'2018-09-07','2018-09-08','2018-09-09','2018-09-10'],
                'user' : ['user1','user1','user2','user3','user3'],
               'number_of_papers' : [3,4,3,2,4]}) 
  </code></pre>
  
  <p>I want to do a group by <code>delivery_date</code> and <code>user</code>. Where:</p>
  
  <ul>
  <li>Finds <code>count</code> of times a <code>user</code> has delivered something in a day.</li>
  <li>Finds <code>sum</code> of <code>number_of_papers</code></li>
  </ul>
  
  <p>I used <code>.agg</code> but I don't think it applies here because the <code>count</code> and <code>sum</code> are about different columns.</p>
  
  <pre><code>df.groupby(['delivery_date','user'])['delivery_date'].agg(['count','sum']).sort_index(level=[0,1], ascending=[False,True]).reset_index(name ='Counts')
  </code></pre>
  
  <blockquote>
    <p>Error TypeError: reduction operation 'sum' not allowed for this dtype</p>
  </blockquote>
  
  <p>The sum should be for <code>number_of_papers</code>. I don't know where to write this in groupby.</p>
  
  <p>Example:
  This does all except the <code>sum</code> part:</p>
  
  <pre><code>a.groupby(['delivery_date','user'])['delivery_date'].count().sort_index(level=[0,1], ascending=[False,True]).reset_index(name ='counts')
  </code></pre>
  
  <p>gives:</p>
  
  <pre><code>delivery_date   user    counts
  0   2018-09-10  user3   1
  1   2018-09-09  user3   1
  2   2018-09-08  user2   1
  3   2018-09-07  user1   2
  </code></pre>
  
  <p>I simply want to also do the <code>sum</code> of <code>number_of_papers</code> in this table as a new column called <code>sum</code>.</p>