the solution I share here for this problem is based on the set, so if the Name of dataframe 1 is at least sharing one word with the Name of dataframe 2, and also their Price is equal then we edit the Flag column in the dataframe 1 by "Delete" otherwise we made it as "None"
This The Code Source :
def check(row):
df1_Name = set(map(lambda word: word.lower(),row.Name.split(' ')))
df1_price = row.Price
df1_flag = row.Flag
for df2_Name, df2_Price in df2[['Name', 'Price']].values:
df2_Name = set(map(lambda word: word.lower(),df2_Name.split(' ')))
if len(df1_Name.intersection(df2_Name)) > 1 and df1_price == df2_Price:
return 'Delete'
return ''
df1["Flag"]= df1.apply(checkMatch,axis=1)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…