[英]Iteration & Computation Pandas Dataframe
As a very very new beginner with Python & Pandas, I am looking for your support regarding an issue.作为 Python 和 Pandas 的新手,我正在寻求您对某个问题的支持。
I need to iterate over columns and find out the maximum value in the concerning rows of a dataframe and write it in a new variable for each row.我需要遍历列并找出数据帧相关行中的最大值,并将其写入每一行的新变量中。 The number of columns is not manageable, almost 200 columns, therefore I do not want to write each required column id manually.列数无法管理,将近 200 列,因此我不想手动编写每个必需的列 id。 And most importantly that I need to start from a given column id and continue with two columns id increments till a given last columns id.最重要的是,我需要从给定的列 id 开始,并继续以两列 id 递增,直到给定的最后一列 id。
Will appreciate sample codes, see attachment too.将欣赏示例代码,请参阅附件。
Try:尝试:
df['x']=df.max(axis=1)
Replace x
with the name for your desired output column.将x
替换为所需输出列的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.