简体   繁体   English

基于关键词的模糊匹配

[英]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 ?有什么方法可以开发模糊匹配逻辑(在 Python 或 R 中)来从df_2df_1查找ID

The match should be based on fuzzy name match, accurate city , state and zip match.匹配应基于模糊name匹配,准确的citystatezip匹配。 If I couldn't find a match in city_1 , I would look for match in city_2 .如果我在city_1找不到匹配city_1 ,我会在city_2查找匹配city_2 If I couldn't find a match in state_1 , I would look for a match in state_2 .如果在state_1找不到匹配state_1 ,我会在state_1查找匹配state_2 The same thing for df_2 . 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 .如果我在NAME_1找不到模糊名称匹配,我会在NAME_2找到一个模糊匹配。

The expected output should be like below:预期输出应如下所示: df_3

Checkout fuzzywuzzy library.结帐fuzzywuzzy库。 It uses Lavenstein distance to compare matches.它使用 Lavenstein 距离来比较匹配。 If you are not convinced by the results, you can use n gram analysis .如果您不相信结果,您可以使用n gram analysis

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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