简体   繁体   English

如何将这三列 dataframe 转换为一列,该列的值在一行中的最大值

[英]how can I transform this three column dataframe to a one column with the value of the column in the highest value in a row

how can I transform this three column dataframe to a one column with the value of the column in the highest value in a row.如何将这三列 dataframe 转换为一列,该列的值在一行中的最大值。 For example, first row becomes -1, second row 1.例如,第一行变为 -1,第二行变为 1。

dataframe overview:- dataframe概述:-

在此处输入图像描述

idxmax is what you looking for idxmax是您要找的

df["max"] = df.idxmax(axis=1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 dataframe 从第一行子集到列中的最大值? - how to subset dataframe from first row to the highest value in a column? Python:在DataFrame中,在新列中为另一列中具有最高值的行添加值,在第三列中添加相同的字符串 - Python: In DataFrame, add value in a new column for row with highest value in another column and string identical in a third one 如何向 pandas dataframe 添加一列,该列在一个范围内具有最高值但将其应用于每一行? - How do I add a column to a pandas dataframe which has the highest value in a range but applying it to every row? 如何在具有另一列最大值的行中的一个 dataframe 列中找到值? - How do I find the value in one dataframe column in the row with the maximum value of another column? 如何为数据框中的每一行分配一个值到不同的列? - How can I assign a value to a different column for each row in a dataframe? 如何在 DataFrame 的同一列上复制前一行的值? - How can I copy the value of a previous row, on the same column in a DataFrame? 如何获取连续熊猫中具有最高值的列的名称 - How do I get the name of the column with the highest value in a row pandas 查找数据框行中第二高值的列标题 - Finding column header for the second highest value in a row of a dataframe 获取 Dataframe Pandas 中最大值的列和行索引 - Get Column and Row Index for Highest Value in Dataframe Pandas 在数据框的给定列中找到最大值的行索引 - Find row-index of highest value in given column of dataframe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM