Spark withColumn sequential integer based on date : <p>I've got a data set that has companies with a daily production rate of a product.  I want to add a column to that dataframe which will sequentially number based on that company by date.</p>

<p>Ex.<br/>
Acme    Product1    1/1/2000    5<br/>
Acme    Product1    1/2/2000    7<br/>
Acme    Product2    3/1/2000    9<br/>
Acme    Product2    3/2/2000    4<br/>
Company2    ProductX    4/1/2015    6<br/>
Company2    ProductX    4/2/2015    3<br/></p>

<p>I want to add a new column like:<br/>
Acme    Product1    1/1/2000    5    <b>1</b><br/>
Acme    Product1    1/2/2000    7    <b>2</b><br/>
Acme    Product2    3/1/2000    9    <b>1</b><br/>
Acme    Product2    3/2/2000    4    <b>2</b><br/>
Company2    ProductX    4/1/2015    6    <b>1</b><br/>
Company2    ProductX    4/2/2015    3    <b>2</b><br/>
Company2    ProductX    4/2/2015    2    <b>3</b><br/></p>

<p>This is all so that I can compare companies and their products based on the new column.  So all of their day one production for a product regardless of date.</p>
