def anti_join(x, y, on):
ans = pd.merge(left=x, right=y, how='left', indicator=True, on=on)
ans = ans.loc[ans._merge == 'left_only', :].drop(columns='_merge')
return ans
def anti_join_all_cols(x, y):
assert set(x.columns.values) == set(y.columns.values)
return anti_join(x, y, x.columns.tolist())
df_anti_join = df_cars.join(df_repairs, on="id", how="anti")