Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有如下数据框:
Idx A B C 0 1 2 3 1 3 4 5 2 2 3 8
数据框 B 列的最大值为 4,我可以从中获取索引df["B"].argmax()为 1。
df["B"].argmax()
现在的问题是,我怎样才能得到数据框列 B 的确切最大值?
谢谢!
In [6]: df Out[6]: A B C Idx 0 1 2 3 1 3 4 5 2 2 3 8 In [7]: df.max() Out[7]: A 3 B 4 C 8 dtype: int64 In [10]: df['B'].max() Out[10]: 4 In [8]: df.idxmax() Out[8]: A 1 B 1 C 2 dtype: int64