I have large pandas dataframe with two columns rider_ID and person_ID given as:
ride_ID person_ID
ride_1 person1
ride_1 person2
ride_1 person3
ride_2 person1
ride_2 person4
ride_3 person1
ride_3 person5
ride_3 person2
ride_3 person3
..... ......
..... ......
For each unique ride_ID the number of person_ID could be anything either 2 or 20 or 100. All, I want to apply groupby on column ride_ID such that column person_ID will reflected into multiple columns with columns name as person_ID1 till person_IDn. Expected output as;
ride_ID person_ID1 person_ID2 person_ID3 person_ID4 person_ID5 ....... person_IDn
ride_1 person1 person2 person3 NaN NaN ......
ride_2 person1 NaN NaN person4 NaN ......
ride_3 person1 person2 person3 NaN person5
personsfor uniqueride_ID. Lets say,ride_44has maximum ride which is50then column names will range fromperson_ID1toperson_ID50and then for each ride the corresponding person will marked.