I have the data like that in a spark.dataframe A :
Ben 1
Ben 2
Ben 4
Ben 3
Jerry 2
Jerry 2
Jane 3
Jane 5
James 1
James 1
We have the Action_id range 1-5. We want to get the spark.dataframe B like that:
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
For example, the '1' in (Ben,Action_id=1) means that in the previous dataframe, Ben take action 1 for one time.
How can I transform the dataframe A to dataframe B ?