I have data where I may have different people associated with the same entry.
I need to combine the two entries together and note that two people are on it.
For example, the data may look like:
Name Share_ID value1 value2 value3 etc.
Joe 0001 1 2 4
Ann 0002 2 5 2
Mel 0001 1 2 4
The output would need to be:
Name Share_ID value1 value2 value3 etc.
Joe, Mel 0001 1 2 4
Ann 0002 2 5 2
I tried to use groupby
df1.groupby(['Share_ID'])['Name'].apply(', '.join).reset_index()
But my result from that was just:
Share_ID Name
0001 Joe, Mel
0002 Ann
The Name column combined correctly, but I lost the other columns. Note that I do not want the other columns to have anything applied to them--Joe and Ann's records are identical.
I think my approach is off, but I'm not sure what function to use.