How can I split a column in pandas DataFrame by variable names in a column? I have a DataFrame below:
ID FEATURE PARAM VALUE
0 A101 U1 ITEM1 10
1 A101 U1 ITEM2 11
2 A101 U2 ITEM1 12
3 A101 U2 ITEM2 13
4 A102 U1 ITEM1 14
5 A102 U1 ITEM2 15
6 A102 U2 ITEM1 16
7 A102 U2 ITEM2 17
I want to split it as below.
ID FEATURE ITEM1 ITEM2
0 A101 U1 10 11
1 A101 U2 12 13
2 A102 U1 14 15
3 A102 U2 16 17
I tried to use one of the responses and it works great but partially.
Select_Data.groupby('PARAM')['VALUE'].apply(list).apply(pd.Series).T
PARAM ITEM1 ITEM2
0 10 11
1 12 13
2 14 15
3 16 17
But I lost my ID & FEATURE columns and I want to keep them in the table. I will greatly appreciate any suggestions.