I work on a dataframe with three columns, colA, colB and colC
+---+-----+-----+-----+
|id |colA |colB |colC |
+---+-----+-----+-----+
| 1 | 5 | 8 | 3 |
| 2 | 9 | 7 | 4 |
| 3 | 3 | 0 | 6 |
| 4 | 1 | 6 | 7 |
+---+-----+-----+-----+
I need to merge the colA, colB and colC columns to get a new dataFrame like that below:
+---+--------------+
|id | colD |
+---+--------------+
| 1 | [5, 8, 3] |
| 2 | [9, 7, 4] |
| 3 | [3, 0, 6] |
| 4 | [1, 6, 7] |
+---+--------------+
That is the pyspark code to obtain the first DataFrame:
l=[(1,5,8,3),(2,9,7,4), (3,3,0,6), (4,1,6,7)]
names=["id","colA","colB","colC"]
db=sqlContext.createDataFrame(l,names)
db.show()
How do I convert rows to Vectors? Could anyone help me, please? Thanks