想把这两列数据
增加一个新列
按00,01,10组合 新列数值为False
11组合, 新列数值为True
求大佬指教
data2['c'] = data2['a'] & data2['b'].astype(bool)
帮你写个完整版的吧:
import pandas as pd
data = {
'a':[1,1,0,0],
'b':[1,0,1,0]
}
df = pd.DataFrame(data)
print(df)
print('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
df['new_col']=list(map(lambda x,y: bool(x and y), df['a'], df['b']))
print(df)