title: compute the rate in pyspark dataframe
body: <p>I have a spark dataframe like this :</p>
  
  <pre><code>date      isF  
  190502     1 
  190502     0 
  190503     1 
  190504     1 
  190504     0 
  190505     1
  </code></pre>
  
  <p>I would like to compute for each date the rate of "isF" when isF =1.
  The expected result is : </p>
  
  <pre><code> date  rate
  190502     0.5 
  190503     1 
  190504     0.5 
  190505     1
  </code></pre>
  
  <p>I tryed somethong like this but here i compute the sum, how can I do to compute the rate? : </p>
  
  <pre><code>stats_daily_df = (tx_wd_df
               .groupBy("date", "isF")
               .agg(# select 
                  when(col("isF") == 1, (sum("isF")).alias("sum"))  
                  .otherwise(0))   # else 0.00
                    )
  </code></pre>