示例数据帧
category Nestle Britania P&G HL
lead 0 1 0 0
Mg 1 0 0 0
Cl 0 0 1 0
首先,我们必须确保每一行都没有一个以上的1。
第二,所需的输出是数据帧
category company_name
lead britania
Mg Nestle
Cl P&G
我试着像下面这样
df['company_name'] = df.apply(lambda row: valuation_formula(row), axis=1)
def valuation_formula(row):
return sent the column name which has result 1
你能帮帮忙吗
https://stackoverflow.com/questions/51313634
复制相似问题