KReEd
KReEd

Reputation: 368

Compare two Column and apply Jaro distance

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

Upvotes: -2

Views: 694

Answers (1)

vagitus
vagitus

Reputation: 486

df['score'] = df.apply(lambda row : jaro.jaro_winkler_metric(row['col1'],
                     row['col2']), axis = 1)

Upvotes: 2

Related Questions