I'm trying to find the duplicates in a dataframe for each group that are higher so I can remove these later from another dataframe based on the index so the main dataframe is left with no duplicates and only the lowest value.

Basically let's say we have this dataframe:

```py
index   group   value
  1       1      402
  2       1      396
  3       2      406
  4       2      416
  5       2      407
  6       2      406
  7       1      200
  8       2      350

```

What I need is to only keep the duplicates in each group of consecutive duplicates that have the highest values and remove the lowest one. The group is 1 or 2 but there can be multiple instances of consecutive values in the same group.
So the resulting dataframe would be:

```py
index   group   value
  1       1      402
  4       2      416
  5       2      407

```

Speed is important too and there has to be no lookahead.