d1 = {'id': ['a','b','c'], 'ref': ['apple','orange','banana']}
df1 = pd.DataFrame(d1)
d2 = {'id': ['a','b','d'], 'ref': ['apple','orange','banana']}
df2 = pd.DataFrame(d2)
I want to see if the column pair of id and ref in df1 exists in df2. I'd like to create a boolean column in df2 to accomplish this.
Desired Output:
d3 = {'id': ['a','b','d'], 'ref': ['apple','orange','banana'], 'check':[True,True,False]}
df2 = pd.DataFrame(d3)
I've tried the following along with a simple assign/isin
df2['check'] = df2[['id','ref']].isin(df1[['id','ref']].values.ravel()).any(axis=1)
df2['check'] = df2.apply(lambda x: x.isin(df1.stack())).any(axis=1)
How can I do this WITHOUT a merge?