title: Dask DataFrame Groupby: Most frequent value of column in aggregate
body: <p>A custom dask <code>GroupBy</code> <a href="https://docs.dask.org/en/latest/dataframe-groupby.html#aggregate" rel="nofollow noreferrer"><code>Aggregation</code></a> is very handy, but I am having trouble to define one working for the <strong>most often value in a column</strong>.</p>
  <p>What do I have:</p>
  <p>So from the example <a href="https://stackoverflow.com/a/15223034/940592">here</a>, we can define custom aggregate functions like this:</p>
  <pre><code>custom_sum = dd.Aggregation('custom_sum', lambda s: s.sum(), lambda s0: s0.sum())
  my_aggregate = {
      'A': custom_sum,
      'B': custom_most_often_value, ### &lt;&lt;&lt; This is the goal.
      'C': ['max','min','mean'],
      'D': ['max','min','mean']
  }
  col_name = 'Z'
  ddf_agg = ddf.groupby(col_name).agg(my_aggregate).compute()
  </code></pre>
  <p>While this works for <code>custom_sum</code> (as on the example page), the adaption to <em>most often value</em> could be like this (<a href="https://stackoverflow.com/a/15223034/940592">from the example here</a>):</p>
  <pre><code>custom_most_often_value = dd.Aggregation('custom_most_often_value', lambda x:x.value_counts().index[0], lambda x0:x0.value_counts().index[0])
  </code></pre>
  <p>but it yields</p>
  <pre><code>ValueError: Metadata inference failed in `_agg_finalize`.
  
  You have supplied a custom function and Dask is unable to 
  determine the type of output that that function returns. 
  </code></pre>
  <p>Then I tried to find the <code>meta</code> keyword in the <a href="https://github.com/dask/dask/pull/4571/files#diff-6e8811cb7ed0ab69a7062d0995e1d540R202" rel="nofollow noreferrer"><code>dd.Aggregation</code> implementation</a> to define it, but could not find it.. And the fact that it is not needed in the example of <code>custom_sum</code> makes me think that the error is somewhere else..</p>
  <p>So my question would be, how to get that <em>mostly occuring value</em> of a column in a <code>df.groupby(..).agg(..)</code>. Thanks!</p>