title: Pyspark, how to convert the raw data into SVMLight format
body: <p>I have one question regarding the Pyspark map.</p>
  <p>For exampel, I have data as follow:</p>
  <pre><code> data=[(1,1,1,10),(1,1,2,20),(2,1,3,15),(2,1,1,47),(3,0,2,28),(3,0,3,17)]
   df=spark.createDataFrame(data).toDF(&quot;ID&quot;,&quot;Target&quot;,&quot;features&quot;,&quot;value1&quot;)
   df.show()
  
   +---+------+--------+------+
   | ID|Target|features|value1|
   +---+------+--------+------+
   |  1|     1|       1|    10|
   |  1|     1|       2|    20|
   |  2|     1|       3|    15|
   |  2|     0|       1|    47|
   |  3|     0|       2|    28|
   |  3|     0|       3|    17|
   +---+------+--------+------+
  </code></pre>
  <p>I want to convert the data looks as: group by ID:</p>
  <pre><code> 1 1:10  2:20
   1 2:15  1:47
   0 2:28  3:17
  </code></pre>
  <p>So each line represent on ID, and the first value represent the Target, and features:value1</p>
  <p>Could you provide any sample code or suggestions?</p>
  <p>Thank you so much!!!!!!!!!!!</p>