I have a dataframe in pandas
where I am using fuzzywuzzy
package in python to match first column in the dataframe with second column.
I hav
You're passed a Series to work with inside the apply
function, representing the current row here. In your code, you're effectively ignoring this Series and trying to call partial_ratio
with the two whole columns of the DataFrame each time (driver[col]
).
A minor change to your code should hopefully give you what you want.
d = DataFrame({'one': ['fuzz', 'wuzz'], 'two': ['fizz', 'woo']})
d.apply(lambda s: fuzz.partial_ratio(s['one'], s['two']), axis=1)
0 75
1 33
dtype: int64
(Interestingly, the partial_ratio
function will accept a Series as input, but only because it converts it internally into a string. :)