pandas中列的最大值位置

时间:2015-10-20 05:42:20

标签: python pandas

我是这个python的新手。考虑我在数据帧中有2列如下:

NextBtn_2.titleEdgeInsets = UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) ;

现在B列中的最大值是8,我需要A列中的值,这里是4.请帮助解决这个问题。提前谢谢。

1 个答案:

答案 0 :(得分:0)

使用idxmax()获取最大值索引,然后引用A列中的索引值

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

哪里

In [8]: df['B'].idxmax()
Out[8]: 2