1

I have this

data

How do i find max value of MMAX, but the vendor must be an "amdahl"?

Should I make a new data manually?
Use Python, pls..

MarianD
  • 11,249
  • 12
  • 32
  • 51

3 Answers3

2

Try using groupby and max:

print(df.groupby('Vendor')['MMAX'].max()['amdahl'])
U12-Forward
  • 65,118
  • 12
  • 70
  • 89
2

You can also use loc:

print(max(df.loc[df['Vendor'] == 'amdahl'].MMAX))
Ishan
  • 414
  • 2
  • 9
0
df[df.Vendor == "amdahl"].MMAX.max()

The explanation:

  • df[df.Vendor == "amdahl"] selects only rows which fulfill the condition in brackets, then
  • .MMAX returns only the NMAX column (as a series), and finally
  • .max() method returns the maximum of that series values.

Note:

A more verbose version of the same approach is using the ["colname"] notations (instead of the abbreviated ones .colname):

df[df["Vendor"] == "amdahl"]["MMAX"].max()
MarianD
  • 11,249
  • 12
  • 32
  • 51