I am trying to change the structure of a PySpark DataFrame.
It is somewhat a transpose representaion.
Can anyone help..?
I tried few methods like explode() and a custom transpose function, but failed to achieve this completely.
Source DF is below-
num name x y z
1 abc 10 20 30
2 def 40 50 60
3 ghi 70 80 90
I want to change it to the below form:
num name variable value
1 abc x 10
2 def y 20
3 ghi z 30
1 abc x 40
2 def y 50
3 ghi z 60
1 abc x 70
2 def y 80
3 ghi z 90