title: Count in pyspark
body: <p>I have a spark dataframe df with a column "id" (string) and another column "values" (array of strings). I want to create another column called count with contains the count of values for each id. </p>
  
  <p>df looks like - </p>
  
  <pre><code>id        values
  1fdf67    [dhjy1,jh87w3,89yt5re]
  df45l1    [hj098,hg45l0,sass65r4,dh6t21]
  </code></pre>
  
  <p>Result should look like -</p>
  
  <pre><code>id        values                          count
  1fdf67    [dhjy1,jh87w3,89yt5re]          3
  df45l1    [hj098,hg45l0,sass65r4,dh6t21]  4
  </code></pre>
  
  <p>I am trying to do as below -</p>
  
  <pre><code>df= df.select(id,values).toDF(id,values,values.count())
  </code></pre>
  
  <p>This doesn't seem to be working for my requirement. </p>