Given this dataframe:
feature score searchTerm
0 a 0.534509 pizza
1 b 0.586020 pizza
2 c 0.588972 pizza
3 a 0.566261 chinese
4 b 0.572405 chinese
5 c 0.489369 chinese
6 a 0.499068 thai
7 b 0.431068 thai
8 c 0.441617 thai
Feature is limited to (a
,b
,c
)
I want to pivot the dataframe into this:
a b c searchTerm
0.534509 0.586020 0.588972 pizza
0.566261 0.572405 0.489369 chinese
0.499068 0.431068 0.441617 thai
...
...
You can use
pivot
:Last you can remove columns name by
rename_axis
(new inpandas
0.18.0
):