[英]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_2
为df_1
查找ID
?
The match should be based on fuzzy name
match, accurate city
, state
and zip
match.匹配应基于模糊name
匹配,准确的city
、 state
和zip
匹配。 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
找到一个模糊匹配。
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.