I have a data frame like this:
df
col1 col2 col3 col4
A B C 12
A B C 8
A B C 10
P Q R 12
P Q R 11
K L S 1
K L S 15
U V R 20
I want to get those rows where col4 value is maximum for col3 values for each col1 and col2 combinations
for example the result I am looking for is
col1 col2 col3 col4
A B C 12
P Q R 12
K L S 15
U V R 20
how to do it in most efficient way using pandas ?
df.groupby(['col1', 'col2', 'col3']).max()
– Simon Rogersdf.groupby(['col1', 'col2', 'col3']).max()
. – Serge Ballesta