Fuzzy Wuzzy String Matching on 2 Large Data Sets Based on a Condition - python Fuzzy Wuzzy String Matching on 2 Large Data Sets Based on a Condition - python pandas pandas

Fuzzy Wuzzy String Matching on 2 Large Data Sets Based on a Condition - python


You could adapt your fuzzy_match function to take the id as a variable and use this to subset your choices before doing the fuzzy search (note that this requires applying the function over the whole dataframe rather than just the address column)

def fuzzy_match(x, choices, scorer, cutoff):    match = process.extractOne(x['Address1'],                                choices=choices.loc[choices['ID'] == x['ID'],                                                    'Address1'],                                scorer=scorer,                                score_cutoff=cutoff)    if match:        return match[0]test['FuzzyAddress1'] = test.apply(fuzzy_match,                                    args=(test2, fuzz.ratio, 80),                                    axis=1)