I have a pandas dataframe storing the value of different metrics for different parameter configuration, such as:
index | param1 | params2 | metric | score |
0 | xx | yy | XXX | 100 |
1 | xx | yy | YYY | 50 |
2 | xx | yy | ZZZ | 20 |
3 | aa | bb | XXX | 200 |
4 | aa | bb | YYY | 50 |
5 | aa | bb | ZZZ | 10 |
I would like to convert it into:
index | param1 | params2 | XXX | YYY | ZZZ |
0 | xx | yy | 100 | 50 | 20 |
1 | aa | bb | 200 | 50 | 10 |
I m trying to do it with pivot, that is
df.pivot(index='index',columns=['metric','param1','param2'],values='score')
but the results is not what I am searching for. Moreover, I am not interested into aggregating the values, just reshaping them.