Search code examples
pythonpandasjaro-winkler

'jarowinkler is not defined' after I run the code correctly the day before


I am getting the following error message:

NameError: name 'jarowinkler' is not defined

This error comes from

from similarity.jarowinkler import JaroWinkler

for word in words:
    df[word] = df.Texts.apply(lambda x: jarowinkler.similarity(x, word)) /* here */
    np.where(df[word] > 0.8, df[word], np.nan)

where words = df.Texts.tolist()

Yesterday I ran the code correctly and without any issues. Any idea on the reason why I am getting this error now?


Solution

    • Add the following to the script
    # call similarity method
    jarowinkler = JaroWinkler()
    
    • Incidentally, this is in the original script, but must have been missed.

    Alternatively

    df[word] = df.Texts.apply(lambda x: JaroWinkler().similarity(x, word))