【发布时间】:2019-11-17 21:49:39
【问题描述】:
我有一个这样的数据框:
A1 A2 A3 ...A99 largest
0 3 4 6 11 11
1 1 8 2 ... 1 8
.
.
.
我使用以下方法创建了每行中包含最大值的列:
data['largest']=data.max(axis=1)
但我也想得到一列,其中包含具有最大数字的相应列名,如下所示:
A1 A2 A3 ...A99 largest name
0 3 4 6 11 11 A99
1 1 8 2 ... 1 8 A2
. .
. .
. .
我尝试了'.idxmax',但给了我一个错误'reduction operation 'argmax' not allowed for this dtype',有人可以帮我吗?非常感谢。
【问题讨论】:
标签: python pandas dataframe max data-science