[英]if two column values are equal then create 3rd column which has True and False values in Python
I want to get 3rd column which would have boolean values ie True and False, say I have column A which has numeric value and column B which also has some numeric value, I need to compare them whether they're equal, so If they're equal then there will be TRUE value in 3rd column, else False in python data frame我想获得具有 boolean 值的第 3 列,即 True 和 False,假设我有 A 列有数值,B 列也有一些数值,我需要比较它们是否相等,所以如果他们重新相等,则第 3 列中的值为 TRUE,否则 python 数据帧中的值为 False
Input:输入:
Output Required Output 需要
df['3rd Column']=df['A']==df['B']
df:
A B Third Column
10 20 FALSE
20 10 FALSE
30 30 TRUE
50 40 FALSE
80 60 FALSE`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.