I am trying to remove consecutive duplicates from column X while keeping the entry with the max value based on column Y, unfortunately with no success. The data frame is as follow:
idx | X | Y |
---|---|---|
0 | A | 3 |
1 | B | 2 |
2 | A | 7 |
3 | A | 10 |
4 | B | 1 |
5 | C | 4 |
6 | A | 3 |
7 | A | 3 |
What I want to achieve is:
idx | X | Y |
---|---|---|
0 | A | 3 |
1 | B | 2 |
3 | A | 10 |
4 | B | 1 |
5 | C | 4 |
7 | A | 3 |
Most of the solutions I found just remove the duplicates tout court without accounting for any repeating pattern.
Please note that the duplicates might have the same value.