Trying to merge duplicate rows with identical columns besides value but want to keep all data that is not duplicated.
I thought a groupby function and resetting the index would allow me to achieve this goal but that obviously did not work.
Tried to run Microsoft Visual Basic for Applications to achieve my goal but it omitted non duplicate data as well.
Was hoping for some pandas or even excel tips or pandas/excel documentation that could assist me.
My Code:
grouped_df = result1.groupby(['ID','Name','Value'])
maximums = grouped_df.max('Price')
maximums = maximums.reset_index()
Dataset before:
ID | Name | Value |
---|---|---|
1 | Apple | 3 |
2 | Banana | 4 |
2 | Banana | 5 |
3 | Orange | 3 |
4 | Pear | 7 |
4 | Pear | 5 |
What I am getting with my code:
ID | Name | Value |
---|---|---|
2 | Banana | 5 |
4 | Pear | 7 |
What I wish to achieve:
ID | Name | Value |
---|---|---|
1 | Apple | 3 |
2 | Banana | 5 |
3 | Orange | 3 |
4 | Pear | 7 |