I have a dataframe, I need to apply Jaro winkler distance, example - jaro.jaro_winkler_metric(u'SHACKLEFORD', u'SHACKELFORD')
dataframe -
col1 | col2 |
---|---|
value1 | value2 |
value3 | value4 |
so basically I have two columns 'col1' & 'col2', I need to compare value1 with value 2 like - jaro.jaro_winkler_metric(u'value1', u'value2')
then value3 with value4 and so on, iteration should continue till last value and get the score in new column
expected output -
col1 | col2 | score |
---|---|---|
value1 | value2 | 0.88 |
value3 | value4 | 0.77 |
please help to build this logic.
CodePudding user response:
df['score'] = df.apply(lambda row : jaro.jaro_winkler_metric(row['col1'],
row['col2']), axis = 1)