I know there are lot of questions about removing duplicates from pandas dataframe but this is bit different.
I am trying to remove duplicates from the dataframe but not getting the actual output as in the below given result dataframe. Actually the data in table is too long. For understanding purpose I have given the dummy data here in the table.
Condition:-
I need to remove duplicates and get the rows that contain max value from diast column.
Is there a good way to get result dataframe using given df.
Any help would be appreciated. Thanks :)
DF:-
| age | syst | diast | a | b | c | d |
|---|---|---|---|---|---|---|
| 29 | 90 | 57 | MO | MO | 0 | MO |
| 29 | 90 | 58 | MO | MO | 0 | MO |
| 29 | 90 | 59 | MO | MO | 0 | MO |
| 29 | 90 | 60 | MO | MO | 0 | MO |
| 29 | 90 | 61 | 0 | 0 | 0 | 0 |
| 29 | 90 | 62 | 0 | 0 | 0 | 0 |
| 29 | 90 | 63 | 0 | 0 | 0 | 0 |
| 29 | 90 | 64 | 0 | 0 | 0 | 0 |
| 29 | 90 | 65 | MO | MO | 0 | MO |
| 29 | 90 | 66 | MO | MO | 0 | MO |
| 29 | 90 | 67 | MO | MO | 0 | MO |
| 29 | 90 | 68 | MO | MO | 0 | MO |
Result:-
| age | syst | diast | a | b | c | d |
|---|---|---|---|---|---|---|
| 29 | 90 | 60 | MO | MO | 0 | MO |
| 29 | 90 | 64 | 0 | 0 | 0 | 0 |
| 29 | 90 | 68 | MO | MO | 0 | MO |