I have dataframe:
df =
original_title title
Mexico Oil Gas Summit
Mexico Oil Gas Summit
I have to fuzzy match the entities of these two(original_title & title) columns and get a score. below is my code:
compare = pd.MultiIndex.from_product([ df['original_title'],df ['title'] ]). to_series()
def metrics (tup):
return pd.Series([fuzz.partial_ratio(*tup),fuzz.token_sort_ratio(*tup)], ['partial', 'token'])
compare.apply(metrics)
The above code compares each original title with the whole column of title. while, I want it to compare each original title with title in each row. My expected outcome would be:
df =
original_title title partial_ratio
Mexico Oil Africa Oil 81
French Property Exhibition French 100
French Exhibition French Exhibition 100
Would appreciate your help. Thanks