我想将地址列表与当前数据库匹配。我使用fuzzy wuzzy
库来匹配基于地址的字符串。
这是我得到的
from fuzzywuzzy import process
import pandas as pd
mega_build = pd.read_csv('Address List.csv')
db = pd.read_csv('Database.csv')
mega_bd_address = mega_build['Building Address']
choices = db['Property Address 1']
for address in mega_bd_address:
top_match = process.extractOne(address, choices)
alt_match = process.extract(address, choices, limit=3)
print top_match,alt_match
我想从我的数据库中返回ID等信息并写入csv文件但不知道如何操作。
我正在寻找的结果示例如下..
ID top_match alt_match
894R ('108 N State Street', 88) [('108 N State Street', 88), ('6916 N. Lakewood Avenue', 85), ('3100 N. Sheridan Road', 85)]
1234 ('11 S. Green', 95) [('11 S. Green', 95), ('123 S. Green St', 86), ('5555 S. Everett Avenue', 85)]
那么如何根据模糊匹配结果合并这两个数据集?