pandas fuzzy matching

Using fuzzywuzzy

Load test data and make dataframes

import pandas as pd
import numpy as np
from fuzzywuzzy import fuzz
from fuzzywuzzy import process

d1={1:'Tim','2':'Ted',3:'Sally',4:'Dick',5:'Ethel'}
d2={1:'Tam','2':'Tid',3:'Sally',4:'Dicky',5:'Aardvark'}

df1=pd.DataFrame.from_dict(d1,orient='index')
df2=pd.DataFrame.from_dict(d2,orient='index')

df1.columns=['Name']
df2.columns=['Name']
df1
Name
1 Tim
2 Ted
3 Sally
4 Dick
5 Ethel
df2
Name
1 Tam
2 Tid
3 Sally
4 Dicky
5 Aardvark
def match(Col1,Col2):
    overall=[]
    for n in Col1:
        result=[(fuzz.partial_ratio(n, n2),n2) 
                for n2 in Col2 if fuzz.partial_ratio(n, n2)>50
               ]
        if len(result):
            result.sort()    
            #print('result {}'.format(result))
            #print("Best M={}".format(result[-1][1]))
            overall.append(result[-1][1])
        else:
            overall.append(" ")
    return overall

print(match(df1.Name,df2.Name))
print(match(df2.Name,df1.Name))
['Tid', 'Tid', 'Sally', 'Dicky', ' ']
['Tim', 'Tim', 'Sally', 'Dick', ' ']