PySpark - Add a new column with a Rank by User
<p>I have this PySpark DataFrame</p>

<pre><code>df = pd.DataFrame(np.array([
    ["aa@gmail.com",2,3], ["aa@gmail.com",5,5],
    ["bb@gmail.com",8,2], ["cc@gmail.com",9,3]
]), columns=['user','movie','rating'])

sparkdf = sqlContext.createDataFrame(df, samplingRatio=0.1)
</code></pre>

<pre class="lang-none prettyprint-override"><code>         user movie rating
aa@gmail.com     2      3
aa@gmail.com     5      5
bb@gmail.com     8      2
cc@gmail.com     9      3
</code></pre>

<p>I need to add a new column with a Rank by User</p>

<p>I want have this output</p>

<pre class="lang-none prettyprint-override"><code>         user  movie rating  Rank
aa@gmail.com     2      3     1
aa@gmail.com     5      5     1
bb@gmail.com     8      2     2
cc@gmail.com     9      3     3
</code></pre>

<p>How can I do that?</p>