gpt4 book ai didi

python - 对于每一行,返回最小值的列名 - pandas

转载 作者:太空宇宙 更新时间:2023-11-03 13:09:57 25 4
gpt4 key购买 nike

<分区>

我正在尝试找到与此问题对应的 pandas

For each row return the column name of the largest value

我想在下面的数据框中添加一个新列,这是每行中最低值的列名。

   Multi-Use  Charging  Performer  Controls  Value for Money  All Rounder
0 1.569541 0.290916 2.396734 0.881500 3.171563 1.950175
1 0.906542 2.296172 0.162809 1.604936 0.730633 0.532835
2 0.442924 0.970764 1.264364 0.295140 2.034826 0.824529
3 0.167663 1.367973 0.877306 0.683562 1.653964 0.444136
4 0.870290 0.547844 1.703054 0.209975 2.476787 1.260371

获取最小值很简单:df.iloc[:, 0:6].min(axis=1)

如何根据最小值返回列名?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com