Here is a detailed approach:
iter1 = df1[['contig', 'position']].itertuples() is_in_other_df = [] for row in iter1: tup2 = df2.itertuples() is_in_other_df.append(row in tup2) df1["InOtherDF"] = is_in_other_df
Then just drop the lines where "InOtherDF" is True . You may need to adjust it slightly to ignore the index when returning tuples of rows.
I think this is a cleaner way using merge
df2["FromDF2"] = True df1 = pandas.merge(df1, df2, left_on=["contig", "position"], right_on=["contig", "position"], how="left") df1[~df1.FromDF2]
source share