You can use idxmax()
it will give you the index for maximum value.
index = data['VALUE'][data['PARAMETER'] == 'Param1'].idxmax()
Now you can use this index to get any columns or the entire row.
data.loc[index, 'Object']
Sample Run:
>>import pandas as pd
>>df = pd.DataFrame({'Object': ['A', 'B','C','D', 'E'], 'PARAMETER': ['Param1', 'Param2', 'Param3', 'Param2', 'Param1'], 'VALUE':[1, 2, 3, 4, 5]})
>>df
Object PARAMETER VALUE
0 A Param1 1
1 B Param2 2
2 C Param3 3
3 D Param2 4
4 E Param1 5
OUTPUT:
The masking:
>>df[df['PARAMETER'] == 'Param1']
Object PARAMETER VALUE
0 A Param1 1
4 E Param1 5
The idxmax()
:
>>df[df['PARAMETER'] == 'Param1']['VALUE'].idxmax()
4
From the masking, as you can notice, maximum index is 4, that's what idxmax()
yields. Now you can use this index to access any column like this:
>>index = df['VALUE'][df['PARAMETER'] == 'Param1'].idxmax()
>>df.loc[index, 'Object']
'E'
or the entire row:
>>df.loc[index]
Object E
PARAMETER Param1
VALUE 5
Name: 4, dtype: object