0

I am newbie to this python.Consider i have 2 columns in a dataframe as follows:

A    B
2    6
3    7
4    8

Now the maximum in column B is 8 and i need the value in column A for that, here its 4. Please help to solve this. Thanks in advance.

Subburaj
  • 5,114
  • 10
  • 44
  • 87
  • similar [question](http://stackoverflow.com/q/24571005) [question2](http://stackoverflow.com/q/10202570) [manual method](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.max.html) – Anantha Raju C Oct 20 '15 at 05:49

1 Answers1

0

Use idxmax() to get the index of max value, and then reference the index value in column A

In [7]: df.ix[df['B'].idxmax(), 'A']
Out[7]: 4

Where

In [8]: df['B'].idxmax()
Out[8]: 2
Zero
  • 74,117
  • 18
  • 147
  • 154
  • Thanks @John Galt , I got it.Dont mistake me, if i want to get the previous value in column A. Then how can i accomplish it. – Subburaj Oct 20 '15 at 05:49