Pandas:在所有列中找到最大值并打印此行

avi*_*iss 1 python-3.x pandas

我有一个包含标准化和缩放数据的大型数据框,其范围应在 0-1 之间。但是当我打印它的最大值时,我得到 - 1.000000002。describe()方法不显示此值。所以我试图找出问题并想打印有问题的一行。我遇到的所有其他答案都在谈论打印具有特定列最大值的行。如何打印包含整个数据帧最大值的行?将感谢您的帮助!

test = pd.DataFrame({'att1'  : [0.1, 0.001, 0.0001,
                            1, 2,
                            0.5, 0, -1, -2],
                   'att2':[0.01, 0.0001, 0.00001,
                            1.1, 2.2,
                            2.37, 0, -1.5, -2.5]})
test.max().max()
Out: 2.37000
Run Code Online (Sandbox Code Playgroud)

想要的结果:

    att1    att2
5   0.5     2.37
Run Code Online (Sandbox Code Playgroud)

UPD: 我更新了测试数据框,因为它引起了混乱(我的错!)。我需要打印一行,其中包含整个数据帧的最大值。

WeN*_*Ben 5

我在idxmax这里使用之后stack

test.iloc[[test.stack().idxmax()[0]]]
Out[154]: 
   att1  att2
5   2.3  2.37
Run Code Online (Sandbox Code Playgroud)