Similar to @locojay suggestion, you can apply difflib's get_close_matches to df2's index and then apply a join:

In [23]: import difflib 

In [24]: difflib.get_close_matches
Out[24]: <function difflib.get_close_matches>

In [25]: df2.index = df2.index.map(lambda x: difflib.get_close_matches(x, df1.index)[0])

In [26]: df2
Out[26]: 
      letter
one        a
two        b
three      c
four       d
five       e

In [31]: df1.join(df2)
Out[31]: 
       number letter
one         1      a
two         2      b
three       3      c
four        4      d
five        5      e

.

If these were columns, in the same vein you could apply to the column then merge:

df1 = DataFrame([[1,'one'],[2,'two'],[3,'three'],[4,'four'],[5,'five']], columns=['number', 'name'])
df2 = DataFrame([['a','one'],['b','too'],['c','three'],['d','fours'],['e','five']], columns=['letter', 'name'])

df2['name'] = df2['name'].apply(lambda x: difflib.get_close_matches(x, df1['name'])[0])
df1.merge(df2)
Answer from Andy Hayden on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-do-fuzzy-matching-on-pandas-dataframe-column-using-python
How to do Fuzzy Matching on Pandas Dataframe Column Using Python? - GeeksforGeeks
July 23, 2025 - fuzz.token_set_ratio: It tries to rule out differences in the strings, it returns the maximum ratio after calculating the ratio on three particular sub-string sets in python ... At first, we will create two dictionaries. Then we will convert it into pandas data frames and create two empty lists for storing the matches later than as shown below:
🌐
DataCamp
datacamp.com › tutorial › fuzzy-string-python
Fuzzy String Matching in Python Tutorial | DataCamp
January 15, 2026 - How to perform simple fuzzy string matching in Python using TheFuzz library. Some advanced fuzzy string matching techniques using TheFuzz advanced matches. How to integrate the TheFuzz library with Pandas.
Discussions

is it possible to do fuzzy match merge with python pandas? - Stack Overflow
I have two DataFrames which I want to merge based on a column. However, due to alternate spellings, different number of spaces, absence/presence of diacritical marks, I would like to be able to mer... More on stackoverflow.com
🌐 stackoverflow.com
Fuzzy search in Pandas dataframe
Split dataset into two, do a cross join, take the difference of the time column against itself after the cross join, filter to <=2, group by and average sensor B column More on reddit.com
🌐 r/learnpython
3
1
August 9, 2021
Python Fuzzy Matching Libraries
None that I know of, but both examples have a Levenshtein distance of 1. You could look at sequencematcher. Soundex is how words sound similar, but not key presses. More on reddit.com
🌐 r/datascience
5
1
June 5, 2023
How can I speed up a fuzzy match?
Did you install fuzzywuzzy[speedup]? You can try the RapidFuzz library - there's several SO posts covering it e.g. https://stackoverflow.com/a/61371170 More on reddit.com
🌐 r/learnpython
8
2
July 20, 2022
🌐
Statology
statology.org › home › how to perform fuzzy matching in pandas (with example)
How to Perform Fuzzy Matching in Pandas (With Example)
March 13, 2022 - The easiest way to perform fuzzy matching in pandas is to use the get_close_matches() function from the difflib package.
🌐
GitHub
github.com › jsoma › fuzzy_pandas
GitHub - jsoma/fuzzy_pandas: Fuzzy matches and merging of datasets in pandas using csvmatch · GitHub
Fuzzy matches and merging of datasets in pandas using csvmatch - jsoma/fuzzy_pandas
Starred by 77 users
Forked by 19 users
Languages   Python
Top answer
1 of 16
111

Similar to @locojay suggestion, you can apply difflib's get_close_matches to df2's index and then apply a join:

In [23]: import difflib 

In [24]: difflib.get_close_matches
Out[24]: <function difflib.get_close_matches>

In [25]: df2.index = df2.index.map(lambda x: difflib.get_close_matches(x, df1.index)[0])

In [26]: df2
Out[26]: 
      letter
one        a
two        b
three      c
four       d
five       e

In [31]: df1.join(df2)
Out[31]: 
       number letter
one         1      a
two         2      b
three       3      c
four        4      d
five        5      e

.

If these were columns, in the same vein you could apply to the column then merge:

df1 = DataFrame([[1,'one'],[2,'two'],[3,'three'],[4,'four'],[5,'five']], columns=['number', 'name'])
df2 = DataFrame([['a','one'],['b','too'],['c','three'],['d','fours'],['e','five']], columns=['letter', 'name'])

df2['name'] = df2['name'].apply(lambda x: difflib.get_close_matches(x, df1['name'])[0])
df1.merge(df2)
2 of 16
79

Using fuzzywuzzy

Since there are no examples with the fuzzywuzzy package, here's a function I wrote which will return all matches based on a threshold you can set as a user:


Example datframe

df1 = pd.DataFrame({'Key':['Apple', 'Banana', 'Orange', 'Strawberry']})
df2 = pd.DataFrame({'Key':['Aple', 'Mango', 'Orag', 'Straw', 'Bannanna', 'Berry']})

# df1
          Key
0       Apple
1      Banana
2      Orange
3  Strawberry

# df2
        Key
0      Aple
1     Mango
2      Orag
3     Straw
4  Bannanna
5     Berry

Function for fuzzy matching

def fuzzy_merge(df_1, df_2, key1, key2, threshold=90, limit=2):
    """
    :param df_1: the left table to join
    :param df_2: the right table to join
    :param key1: key column of the left table
    :param key2: key column of the right table
    :param threshold: how close the matches should be to return a match, based on Levenshtein distance
    :param limit: the amount of matches that will get returned, these are sorted high to low
    :return: dataframe with boths keys and matches
    """
    s = df_2[key2].tolist()
    
    m = df_1[key1].apply(lambda x: process.extract(x, s, limit=limit))    
    df_1['matches'] = m
    
    m2 = df_1['matches'].apply(lambda x: ', '.join([i[0] for i in x if i[1] >= threshold]))
    df_1['matches'] = m2
    
    return df_1

Using our function on the dataframes: #1

from fuzzywuzzy import fuzz
from fuzzywuzzy import process

fuzzy_merge(df1, df2, 'Key', 'Key', threshold=80)

          Key       matches
0       Apple          Aple
1      Banana      Bannanna
2      Orange          Orag
3  Strawberry  Straw, Berry

Using our function on the dataframes: #2

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

fuzzy_merge(df1, df2, 'Col1', 'Col2', 80)

        Col1  matches
0  Microsoft  Mcrsoft
1     Google    gogle
2     Amazon   Amason
3        IBM         

Installation:

Pip

pip install fuzzywuzzy

Anaconda

conda install -c conda-forge fuzzywuzzy
🌐
HAR Data Extractor
jonathansoma.com › lede › algorithms-2017 › classes › fuzziness-matplotlib › fuzzing-matching-in-pandas-with-fuzzywuzzy
Fuzzing matching in pandas with fuzzywuzzy
Fuzzy matches are incomplete or inexact matches. The Python package fuzzywuzzy has a few functions that can help you, although they’re a little bit confusing!
🌐
PyPI
pypi.org › project › fuzzy-pandas
fuzzy-pandas · PyPI
A razor-thin layer over csvmatch that allows you to do fuzzy mathing with pandas dataframes.
      » pip install fuzzy-pandas
    
Published   Aug 05, 2019
Version   0.1
Find elsewhere
🌐
Medium
medium.com › analytics-vidhya › matching-messy-pandas-columns-with-fuzzywuzzy-4adda6c7994f
Matching Messy Pandas columns with FuzzyWuzzy | by Khalid El Mouloudi | Analytics Vidhya | Medium
February 1, 2024 - In this article, I’m going to show you how to use the Python package FuzzyWuzzy to match two Pandas dataframe columns based on string similarity; the intended outcome is to have each value of column A matched with the closest corresponding ...
🌐
Medium
medium.com › data-science › how-to-do-fuzzy-matching-in-python-pandas-dataframe-6ce3025834a6
How To Do Fuzzy Matching on Pandas Dataframe Column Using Python? | by Sankarshana Kadambari | TDS Archive | Medium
September 26, 2019 - Fuzz has various methods where you can compare strings such as ratio(),partial_ratio(),Token_Sort_Ratio(),Token_Set_Ratio().Now the next question when to use which fuzz function. You can read it here the scenarios are very well explained. Also, I will provide references in the end where it is explained further in detail along with code. ... import pandas as pd from fuzzywuzzy import fuzz from fuzzywuzzy import processdef checker(wrong_options,correct_options): names_array=[] ratio_array=[] for wrong_option in wrong_options: if wrong_option in correct_options: names_array.append(wrong_option) ratio_array.append(‘100’) else: x=process.
🌐
Finxter
blog.finxter.com › 5-best-ways-to-do-fuzzy-matching-on-a-pandas-dataframe-column-using-python
5 Best Ways to Do Fuzzy Matching on a Pandas DataFrame Column Using Python – Be on the Right Side of Change
In this code snippet, we use RapidFuzz’s extractOne method with the fuzz.WRatio scorer to perform fuzzy matching. It returns the best match found in the ‘Company’ column for the string ‘Beta Corp’ along with the similarity score. String Grouper is a Python library designed to cluster strings that have a high similarity score.
🌐
Towards Data Science
towardsdatascience.com › home › latest › how to do fuzzy string matching in pandas dataframes
How to Do Fuzzy String Matching in Pandas Dataframes | Towards Data Science
January 20, 2025 - # Example 2: Calculate Jaccard similarity ratio = fuzz.ratio("apple", "banana") print(ratio) # Output: 18 # Example 3: Calculate cosine similarity cosine_sim = fuzz.token_sort_ratio("apple", "banana") print(cosine_sim) # Output: 18 # Example 4: Calculate partial ratio partial_ratio = fuzz.partial_ratio("apple", "banana") print(partial_ratio) # Output: 20 # Example 5: Calculate token set ratio token_set_ratio = fuzz.token_set_ratio("apple is a fruit", "a fruit is an apple") print(token_set_ratio) # Output: 100 · Maintain Clean Python Code With Black and GitHub Actions. One of the common challe
🌐
Practical Business Python
pbpython.com › record-linking.html
Python Tools for Record Linking and Fuzzy Matching - Practical Business Python
The python ecosystem contains two useful libraries that can take data sets and use multiple algorithms to try to match them together. Fuzzymatcher uses sqlite’s full text search to simply match two pandas DataFrames together using probabilistic record linkage.
🌐
Medium
medium.com › @whyamit101 › understanding-pandas-fuzzy-match-e95299709be5
Understanding pandas fuzzy match. The biggest lie in data science? That… | by why amit | Medium
April 12, 2025 - In the context of pandas, fuzzy matching allows us to compare data frames where the entries may have slight variations due to human error or formatting differences.
🌐
Medium
medium.com › @chavanrohit › fuzzy-string-matching-in-python-with-pandas-and-thefuzz-ab592de88d92
A practical guide using Pandas and TheFuzz to tackle messy data, perform record linkage, and clean datasets with fuzzy matching techniques in Python. | Medium
May 30, 2025 - Learn how to perform fuzzy string matching in Python using Pandas and the thefuzz library. Tackle inconsistent data, link records, and clean datasets effectively with Levenshtein distance and partial ratio matching. Ideal for data cleaning and record linkage tasks.
🌐
Victorangeloblancada
victorangeloblancada.github.io › blog › 2024 › 03 › 02 › fuzzy-matching-in-python.html
Fuzzy Matching in Python
March 2, 2024 - # Import fuzzy matching libraries from thefuzz import process # Load the two dataframes you want to fuzzy match df_1 = pd.read_excel('file_1.xlsx') df_2 = pd.read_excel('file_2.xlsx') # The column name to match in df_1 col_1 = 'column' # The column name to match in df_2 col_2 = 'column' # Create column of match result object.
🌐
Predictivehacks
predictivehacks.com › fuzzy-joins-tutorial
Fuzzy Joins Tutorial – Predictive Hacks
Below we provide the two hypothetical data frames: import pandas as pd from fuzzywuzzy import fuzz from fuzzywuzzy import process import textdistance df1 = pd.DataFrame({'Text_A':['12 Estias Street, Ampelokipi', 'Georgios Pipis', 'fuzzy much in python', 'Today is ...
🌐
Bryan Ross
rossbj92.github.io › Fuzzy-Matching
Fuzzy String Matching with Pandas and fuzzywuzzy - Bryan Ross
February 8, 2020 - Below, we inner join pre_experiment and post_experiment based on matching values in pre_experiment['participant'] and post_experiment['fuzzy_match']. For the moment, we need to explicitly state these or Pandas will attempt to use post_experiment['participant'], which will give us the same result ...
🌐
GitHub
github.com › RobinL › fuzzymatcher
GitHub - RobinL/fuzzymatcher: Record linking package that fuzzy matches two Python pandas dataframes using sqlite3 fts4 · GitHub
A Python package that allows the user to fuzzy match two pandas dataframes based on one or more common fields.
Starred by 286 users
Forked by 60 users
Languages   Python 81.3% | Jupyter Notebook 18.7%
🌐
Kiwiphrases
kiwiphrases.github.io › research › 2019 › 06 › 29 › fuzzy-matching.html
Fuzzy Matching in Pandas (Python) | The Blog and Site of Gene Burinskiy
June 29, 2019 - Indeed, for strings, check out this great stack question and even Pandas now has a method pd.merge_asof though good luck on making the latter work. Here, I provide a quick alternative to the above solutions as derived from my stack question. This solution is good for a few reasons: Works fast on relatively large data without memory overruns · You can track unmatched and their closest matched elements
🌐
Bomberbot
bomberbot.com › python › fuzzy-matching-on-pandas-dataframe-columns-a-python-deep-dive
Fuzzy Matching on Pandas DataFrame Columns: A Python Deep Dive - Bomberbot
This is where fuzzy matching comes into play, offering a powerful solution for data scientists and Python enthusiasts alike. Fuzzy matching, also known as approximate string matching, is a technique that finds strings that approximately match a pattern. It's an invaluable tool when working ...