title: Pandas aggragation error (an integer is required)
body: <pre><code>df_act = pd.DataFrame({'A': {0: 'CHEMBL264', 1: 'CHEMBL4124', 2: 'CHEMBL264', 3: 'CHEMBL233', 4: 'CHEMBL233', 5: 'CHEMBL237', 6: 'CHEMBL236', 7: 'CHEMBL312', 8: 'CHEMBL3820', 9: 'CHEMBL3820'}, 'B': {0: 8.6999999999999993, 1: 8.1600000000000001, 2: 8.3000000000000007, 3: 7.2400000000000002, 4: 8.0, 5: 6.1600000000000001, 6: 6.4400000000000004, 7: 4.8200000000000003, 8: 7.5899999999999999, 9: 7.4299999999999997}})
  </code></pre>
  
  <p>Doing this works:</p>
  
  <pre><code>df_act.groupby(['A'])['B'].median()
  </code></pre>
  
  <p>However, using a custom function to apply it on the groupby object fails:</p>
  
  <pre><code>def fun(x):
       name = {'B_median': x['B'].median()}
       return(pd.Series(names, index = ['B_median']))
  
  df_act.groupby(['A'])['B'].apply(fun)
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>    ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5126)()
  
  pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item (pandas/_libs/hashtable.c:14010)()
  
  TypeError: an integer is required
  </code></pre>
  
  <p>Of course, in both examples I am using the same dataframe, so I don't understand the error.</p>
  
  <p>Edit: add df_act definition</p>