title: How to apply the describe function after grouping a PySpark DataFrame?
body: <p>I want to find the cleanest way to apply the <code>describe</code> function to a grouped DataFrame (this question can also grow to apply any DF function to a grouped DF)</p>
  
  <p>I tested grouped aggregate pandas UDF with no luck. There's always a way of doing it by passing each statistics inside the <code>agg</code> function but that's not the proper way.</p>
  
  <p>If we have a sample dataframe: </p>
  
  <pre class="lang-py prettyprint-override"><code>df = spark.createDataFrame(
      [(1, 1.0), (1, 2.0), (2, 3.0), (2, 5.0), (2, 10.0)],
      ("id", "v"))
  </code></pre>
  
  <p>The idea would be to do something similar to Pandas:</p>
  
  <pre class="lang-py prettyprint-override"><code>df.groupby("id").describe()
  </code></pre>
  
  <p>where the result would be:</p>
  
  <pre class="lang-py prettyprint-override"><code>                                                   v
      count mean     std    min   25%    50%  75%   max
  id                              
  1   2.0   1.5   0.707107  1.0   1.25   1.5  1.75  2.0
  2   3.0   6.0   3.605551  3.0   4.00   5.0  7.50  10.0
  </code></pre>
  
  <p>Thanks.</p>