how to combine rows with a key and keep the highest value Pandas

I have one dataframe with several rows and several columns and I need to keep the values from the other columns a,b,c by combining it into a single row of the corresponding key.

Key, ColA, ColB, Colc
111  0     12    0
111  12    0     0
111  0     0     12
222  12    0     0
222  0     0     12

and the output I want is

key, ColA, ColB, ColC
111  12    12    12
222  12    0     12

Thanks for any help

>Solution :

Keep the max of each group:

>>> df.groupby('Key', as_index=False).max()

   Key  ColA  ColB  Colc
0  111    12    12    12
1  222    12     0    12

Leave a Reply