Suppose I have two dataframes
df1 = pd.DataFrame({"A" : [1,1,2,5], "B" : [1,1,4,5], "C" : ["Adam","Bella","Charlie","Dan"]}) df2 = pd.DataFrame({"A" : [1,1,3,5], "B" : [1,3,6,5]}) and I want to delete the rows in df1 that have the same values of A and B with df2
I do this by
for i, row_1 in df1.iterrows(): for j, row_2 in df2.iterrows(): if row_1["A"] == row_2["A"] and row_1["B"] == row_2["B"]: index = i df1.drop([index], axis=0, inplace=False) which resulted in, as intended
A B C 2 2 4 Charlie I was wondering if there was a much easier/faster way to do this especially if the data frame is large then it is not ideal to iterate over all the rows.