title: pyspark row number dataframe
body: <p>I have a dataframe, with columns time,a,b,c,d,val.
  I would like to create a dataframe, with additional column, that will contain the row number of the row, within each group, where a,b,c,d is a group key.</p>
  
  <p>I tried with spark sql, by defining a window function, in particular, in sql it will look like this:</p>
  
  <pre><code>select time, a,b,c,d,val, row_number() over(partition by a,b,c,d order by     time) as rn from table
  group by a,b,c,d,val
  </code></pre>
  
  <p>I would like to do this on the dataframe itslef, without using sparksql.</p>
  
  <p>Thanks</p>