I have a pandas dataframe like so :
id code mean count
1 A 32 22
1 B 9 56
1 C 25 78
2 A 33 35
2 B 11 66
Basically, for every ID there might be N number of entries and N varies for each ID, for some it might be 1, 2 for some it might be 3 or more. I want to concatenate all rows having the same ID. I know some columns will end up empty for some IDs since their 'N' will be lower as compared to the N of other IDs so I want to fill out -1 for those empty columns
Final dataframe will look like this:
id code1 mean1 count1 code2 mean2 count2 code3 mean3 count3
1 A 32 22 B 9 56 C 25 78
2 A 33 35 B 11 66 -1 -1 -1
Please ask for any additional info that might be required.
EDIT
Please take care that you are using vanilla pandas and NOT modin.pandas or any other version of pandas. I ran into problems while trying to execute the problem when using modin.pandas but vanilla pandas works just fine.