title: How to transpose column to row with PySpark
body: <p>I'm trying to transpose some columns of my table to row. I found the previous post:  <a href="https://stackoverflow.com/questions/37864222/transpose-column-to-row-with-spark">Transpose column to row with Spark</a></p>
  
  <p>I actually want the opposite way. Initially, I have:</p>
  
  <pre><code>+-----+--------+-----------+   
  |  A  | col_id | col_value |  
  +-----+--------+-----------+  
  |  1  |   col_1|        0.0|  
  |  1  |   col_2|        0.6|       
  |  ...|     ...|        ...|        
  |  2  |   col_1|        0.6|  
  |  2  |   col_2|        0.7|   
  |  ...|     ...|        ...|      
  |  3  |   col_1|        0.5|  
  |  3  |   col_2|        0.9|  
  |  ...|     ...|        ...|  
  </code></pre>
  
  <p>And what I want is:</p>
  
  <pre><code>+-----+-----+-----+-------+  
  |  A  |col_1|col_2|col_...|  
  +-----+-------------------+  
  |  1  |  0.0|  0.6|  ...  |  
  |  2  |  0.6|  0.7|  ...  |  
  |  3  |  0.5|  0.9|  ...  |  
  |  ...|  ...|  ...|  ...  |  
  </code></pre>
  
  <p>How can I do it? Thanks!</p>