I have the following pandas data frame:
user_id label avg_price
--------------------------------
11 A 217.3
11 B 312.1
11 C 1079.8
14 A 453.1
14 B 125.4
and here is my desired output:
user_id A_avg_price B_avg_price C_avg_price
---------------------------------------------------------
11 217.3 312.1 1079.8
14 453.1 125.4 na
My current approach is to loop over the pandas dataframe, collecting data for each user and create a new dataset from it. However, I am wondering if there is a much elegant way to solve this problem? Thanks a lot!