title: Groupby and divide count of grouped elements in pyspark data frame
body: <p>I have a data frame in <code>pyspark</code> like below. I want to do <code>groupby</code> and count of <code>category</code> column in <code>data frame</code></p>
  
  <pre><code>df.show()
  +--------+----+
  |category| val|
  +--------+----+
  |    cat1|  13|
  |    cat2|  12|
  |    cat2|  14|
  |    cat3|  23|
  |    cat1|  20|
  |    cat1|  10|
  |    cat2|  30|
  |    cat3|  11|
  |    cat1|   7|
  |    cat1|   8|
  +--------+----+
  
  
  res = df.groupBy('category').count()
  
  res.show()
  
  +--------+-----+
  |category|count|
  +--------+-----+
  |    cat2|    3|
  |    cat3|    2|
  |    cat1|    5|
  +--------+-----+
  </code></pre>
  
  <p>I am getting my desired result. Now I want to calculate the <code>average</code> of category. <code>data frame</code> has records for 3 days. I want to calculate average of count for these 3 days.</p>
  
  <p>The result I want is below. I basically want to do <code>count/no.of.days</code> </p>
  
  <pre><code>+--------+-----+
  |category|count|
  +--------+-----+
  |    cat2|    1|
  |    cat3|    1|
  |    cat1|    2|
  +--------+-----+
  </code></pre>
  
  <p>How can I do that?</p>