使用熊猫将值映射到字典

时间:2020-05-15 21:16:37

标签: python pandas mapping

Can someone explain why am I not getting the desired output of a single integer in the AIOT columns?[1] 有人可以解释为什么我无法在AIOT列中获得所需的单个整数输出吗?

1 个答案:

答案 0 :(得分:0)

按照书面规定,您的代码将每个'AIOT'替换为整个系列 df.A*df.B*...。因此,您会在所有值上看到相同的数字。也许你是说:

df['checkvalidation'] = np.where(df['Course'].eq('AIOT'), 
                                 df.A*df.B*df.C*df.D*df.E,
                                 np.nan)