I have the one excel file which contains the below values
I need to compare a_id value with all the value of b_id and if it matche
a_id
b_id
Use Series.isin for test membership:
df1['a_flag'] = df3['a_id'].isin(df3['b_id']).astype(int) df1['b_flag'] = df3['b_id'].isin(df3['a_id']).astype(int)