I have a data like
| deviceType | category | date | score |
|---|---|---|---|
| A | soccer | 07012022 | 10 |
| A | baseball | 07012022 | 8 |
| B | basketball | 07012022 | 9 |
| A | soccer | 07022022 | 9 |
and I would like to convert it to
| category | A | B | C...(device types so on) |
|---|---|---|---|
| soccer | basketball | ||
| baseball |
which displays category values under each device type in descending order of average of that category scores (soccer is above baseball for device type A as its average score, 9.5, is higher than average score of baseball, 8)
I was trying this with using groupby with two columns (deviceType and category), but I couldn't figure out how to put one column's value under another.
I will appreciate any help.