Используйте лямбда-функцию с DataFrame.apply
:
from fuzzywuzzy import fuzz
df['Ratio'] = df.apply(lambda x: fuzz.ratio(x.A, x.B), axis=1)
#alternative with list comprehension
#df['Ratio'] = [fuzz.ratio(a, b) for a,b in zip(df.A, df.B)]
print (df)
A B Ratio
0 Something Something Else 78
1 Everything Evythn 75
2 Someone Cat 0
3 Everyone Evr1 50
РЕДАКТИРОВАТЬ:
Если возможно, некоторые пропущенные значения в столбцах не удалось, поэтому добавлено DataFrame.dropna
:
print (df)
A B
0 Something Something Else
1 Everything NaN
2 Someone Cat
3 Everyone Evr1
from fuzzywuzzy import fuzz
df['Ratio'] = df.dropna(subset=['A', 'B']).apply(lambda x: fuzz.ratio(x.A, x.B), axis=1)
print (df)
A B Ratio
0 Something Something Else 78.0
1 Everything NaN NaN
2 Someone Cat 0.0
3 Everyone Evr1 50.0