I have to perform a transform operation on pyspark dataframe which is similar to pandas transform. I got below pyspark-dataframe by applying .summary() operation on dataframe.
value col_a col_b col_c
count 14.000000 14.000000 14.000000
mean 9.928571 3189.785714 155210.857143
std 7.086979 1413.286904 76682.259154
min 0.000000 0.000000 0.000000
25% 5.500000 3152.500000 129994.750000
50% 9.500000 3596.000000 158677.500000
75% 12.500000 4007.250000 210596.750000
max 23.000000 4543.000000 256496.000000
And I want to convert rows into columns and columns to rows. Like below
value count mean std min 25% 50% 75% max
col_a 14.0 9.928571 7.086979 0.0 5.50 9.5 12.50 23.0
col_b 14.0 3189.785714 1413.286904 0.0 3152.50 3596.0 4007.25 4543.0
col_c 14.0 155210.857143 76682.259154 0.0 129994.75 158677.5 210596.75 256496.0
Also, columns before transform are not fixed.For problem explanation i have taken 3 columns col_a, col_b, col_c. But in a real scenario, it is up to 10k.
In pandas same I can achieve by doing like below:-
transformed_df = df.T