Python Answers

How to do fuzzy match merge with Python Pandas?

Spread the love

To do fuzzy match merge with Python Pandas, we can use the fuzzymatcher library.

To install it, we run

pip install fuzzymatcher 

Then we use it by writing

from fuzzymatcher import link_table, fuzzy_left_join

df1 = pd.DataFrame({'Col1':['Microsoft', 'Google', 'Amazon', 'IBM']})
df2 = pd.DataFrame({'Col2':['Mcrsoft', 'gogle', 'Amason', 'BIM']})

left_on = ["Col1", "Col2"]
right_on = ["Col2", "Col2"]

fuzzymatcher.link_table(df1, df2, left_on, right_on)

to create 2 dataframes df1 and df2.

Then we call the fuzzymatcher.link_table method to merge df1 and df2 on the columns listed in left_on and right_on.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *