这是我解决的方法:
df1 = pd.Dataframe({"A":['AA','AD','AD'], "B":['BA','BD','BF']})df2 = pd.Dataframe({"A":['AA','AD'], 'B':['BA','BF']})df1['compressed']=df1.apply(lambda x:'%s%s' % (x['A'],x['B']),axis=1)df2['compressed']=df2.apply(lambda x:'%s%s' % (x['A'],x['B']),axis=1)df1['Success'] = df1['compressed'].isin(df2['compressed']).astype(int)print df1 A B compressed Success0 AA BA AABA 11 AD BD ADBD 02 AD BF ADBF 1
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)