【发布时间】:2015-04-17 00:11:12
【问题描述】:
假设我有一个如下所示的数据框。我在 Stackoverflow 上找到的大多数建议旨在从 one 列中获取最大值,然后返回行索引。 我想知道是否有办法通过扫描两个或更多列的最大值来返回数据帧的行索引。
总结一下,从下面的例子中,我想得到行:
11 building_footprint_sum 0.003 0.470
保存数据帧的最大值
+----+-------------------------+--------------------+-------------------+
| id | plot_name | rsquare_allotments | rsquare_block_dev |
+----+-------------------------+--------------------+-------------------+
| 6 | building_footprint_max | 0.002 | 0.421 |
| 7 | building_footprint_mean | 0.002 | 0.354 |
| 8 | building_footprint_med | 0.002 | 0.350 |
| 9 | building_footprint_min | 0.002 | 0.278 |
| 10 | building_footprint_sd | 0.003 | 0.052 |
| 11 | building_footprint_sum | 0.003 | 0.470 |
+----+-------------------------+--------------------+-------------------+
有没有一种相当简单的方法来实现这一点?
【问题讨论】:
-
是否确定每一列的最大值都在同一行?如果不是,则其中一列必须优先,否则您将需要一些决策规则,例如使用两列的总和。