How do I transpose columns in Pyspark? I want to make columns become rows, and rows become the columns.
Here is the input:
+---- +------+-----+-----+
|idx | vin |cur | mean|
+---- +------+-----+-----+
|Type1| D| 5.0 |6.0 |
|Type2| C| null| 7.0 |
+---- +------+-----+-----+
Expected Outcome:
+---- +------+-----+
|idx |Type1 |Type2|
+---- +------+-----+
|vin | D | C |
|cur | 5.0 | null|
|mean | 6.0 | 7.0 |
+-----+------+-----+