I have a dataset like below and i need all the different weights for each category in single row and the count
Sample_data
  category  weights
1  aa        3.2
2  aa        2.2
3  aa        4.2
4  bb        3.5
5  bb        4.5
6  aa        0.5
7  cc        0.6
8  bb        7.5
9  cc        6.6
10 dd        2.2
11 aa        3.3
12 bb        4.4
13 cc        5.5
14 dd        6.6
And what i need is the count of each unique category and the different weights of each category in the same row.
Expected output:
 category count  weight1  weight2  weight3  weight4  weight5   
1 aa      5      3.2      2.2      4.2      0.5      3.3
2 bb      4      3.5      4.5      7.5      4.4
3 cc      3      0.6      6.6      5.5
4 dd      2      2.2      6.6
I thought
sampledata['category'].groupby(level = 0)   
will work but it is not. Can some one help me how to do this in python.
 
     
     
     
    