简体   繁体   中英

Fuzzy Match based on Key Words

I have two tables

df_1

在此处输入图片说明

df_2

在此处输入图片说明

Is there any way I could develop a fuzzy match logic (either in Python or in R) to find ID from df_2 for df_1 ?

The match should be based on fuzzy name match, accurate city , state and zip match. If I couldn't find a match in city_1 , I would look for match in city_2 . If I couldn't find a match in state_1 , I would look for a match in state_2 . The same thing for df_2 . If I couldn't find a fuzzy name match in NAME_1 , I would go to find a fuzzy match at NAME_2 .

The expected output should be like below: df_3

Checkout fuzzywuzzy library. It uses Lavenstein distance to compare matches. If you are not convinced by the results, you can use n gram analysis .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM