title: How to encode the grouped data in spark.dataframe?
body: <p>I have the data like that in a spark.dataframe A :</p>
  
  <pre><code>Ben       1
  Ben       2
  Ben       4
  Ben       3
  Jerry     2
  Jerry     2
  Jane      3
  Jane      5
  James     1
  James     1
  </code></pre>
  
  <p>We have the Action_id range 1-5.
  We want to get the spark.dataframe B like that:</p>
  
  <pre><code>Name     Action_id=1    Action_id=2   Action_id=3  Action_id=4  Action_id=5
  Ben          1              1            1               1            0
  Jane         0              0            1               0            1
  Jerry        0              2            0               0            0            
  James        2              0            0               0            0
  </code></pre>
  
  <p>For example, the '1' in (Ben,Action_id=1) means that in the previous dataframe, Ben take action 1 for one time. </p>
  
  <p>How can I transform the dataframe A to dataframe B ?</p>