title: Group By, Rank and aggregate spark data frame using pyspark
body: <p>I have a dataframe that looks like:</p>
  
  <pre><code>A     B    C
  ---------------
  A1    B1   0.8
  A1    B2   0.55
  A1    B3   0.43
  
  A2    B1   0.7
  A2    B2   0.5
  A2    B3   0.5
  
  A3    B1   0.2
  A3    B2   0.3
  A3    B3   0.4
  </code></pre>
  
  <p>How do I convert the column 'C' to the relative rank(higher score->better rank) per column A? Expected Output:</p>
  
  <pre><code>A     B    Rank
  ---------------
  A1    B1   1
  A1    B2   2
  A1    B3   3
  
  A2    B1   1
  A2    B2   2
  A2    B3   2
  
  A3    B1   3
  A3    B2   2
  A3    B3   1
  </code></pre>
  
  <p>The ultimate state I want to reach is to aggregate column B and store the ranks for each A:</p>
  
  <p>Example: </p>
  
  <pre><code>B    Ranks
  B1   [1,1,3]
  B2   [2,2,2]
  B3   [3,2,1]
  </code></pre>