module 'fuzzywuzzy' has no attribute 'extractOne'

Question:

Im trying to use for the first time the fuzzywuzzy library, but its giving to me an error with the following code

    import fuzzywuzzy as fuzz


def join_fuzzy(df1, df2, key1, key2, threshold=90, limit=1): 
    s = df2[key2].tolist()
    match_dict = {}
    for i in df1[key1]:
        match = fuzz.extractOne(i, s)
        if match[1] >= threshold:
            match_dict[i] = match[0]
    df_output = df1.merge(df2, left_on=key1, right_on=key2, how='left')
    df_output[key2] = df_output[key1].map(match_dict)
    return df_output

df=join_fuzzy(categoriasdf, descripciones, 'Empresas', 'Razón Social Empresa')

I dont understand the reason, cause extractOne is writed as expected. Any idea?

Asked By: lasagna

||

Answers:

extractOne is available from fuzzywuzzy.process.

from fuzzywuzzy import process
# ...
process.extractOne(i, s)
Answered By: Unmitigated
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.