There is a package called thefuzz. Install via pip:

pip install thefuzz

Simple usage:

>>> from thefuzz import fuzz
>>> fuzz.ratio("this is a test", "this is a test!")
    97

The package is built on top of difflib. Why not just use that, you ask? Apart from being a bit simpler, it has a number of different matching methods (like token order insensitivity, partial string matching) which make it more powerful in practice. The process.extract functions are especially useful: find the best matching strings and ratios from a set. From their readme:

Partial Ratio

>>> fuzz.partial_ratio("this is a test", "this is a test!")
    100

Token Sort Ratio

>>> fuzz.ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear")
    90
>>> fuzz.token_sort_ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear")
    100

Token Set Ratio

>>> fuzz.token_sort_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
    84
>>> fuzz.token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
    100

Process

>>> choices = ["Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys"]
>>> process.extract("new york jets", choices, limit=2)
    [('New York Jets', 100), ('New York Giants', 78)]
>>> process.extractOne("cowboys", choices)
    ("Dallas Cowboys", 90)
Answer from congusbongus on Stack Overflow
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ fuzzy-string-python
Fuzzy String Matching in Python Tutorial | DataCamp
January 15, 2026 - Master Python for data science and gain in-demand skills. ... The fuzzy string matching algorithm seeks to determine the degree of closeness between two different strings.
๐ŸŒ
Typesense
typesense.org โ€บ posts โ€บ fuzzy string matching in python (with examples)
Fuzzy string matching in Python (with examples) | Typesense
Like the python-Levenshtein library, it also has a ratio function: from fuzzywuzzy import fuzz str1 = 'But I have promises to keep, and miles to go before I sleep.' str2 = 'But I have many promises to keep, and miles to run before sleep.' ratio = fuzz.ratio(str1, str2) The library also provides advanced functions for handling other complex string matching scenarios.
Discussions

Fuzzy Matching or Other Alternativies?
Correct: Los Angeles@!#@!# Thant's correct? It's a difficult problem in general. One approach is to start with a list of known correct place names. Then probably a combination of approaches removing extraneous stuff that can't be part of the name, like punctuation, unicode, whatever possibly you may be able to remove tokens you know are wrong, by having a "known bad token" list, like Alberta, CA, TX etc Doing fuzzy matching from the "cleaned" string to the known good list. There's some description here: https://www.datacamp.com/tutorial/fuzzy-string-python I know there are a few "fuzzy string matchers" in python, I don't know a lot about any of them, but "thefuzz" seems to implement quite a few of the methods I know about. Note that there are some confounding factors. You can't just remove "CA" blindly because what if there's a now called "Cannibal" which would be "nnibal" if you removed the CA It's definitely not a trivial task and in the end I think you'll have to do a lot of "babysitting" and checking of the results. More on reddit.com
๐ŸŒ r/learnpython
14
3
March 24, 2024
Fuzzy Logic Matching in Python

The built-in difflib module has the get_close_matches() method.

More on reddit.com
๐ŸŒ r/learnpython
1
1
May 18, 2022
Unsupervised Learning for String Matching in Python - can I have advice on how to go about this?
Make new features with the fuzzy library after you have a binary classification problem you can try knn classifier even catboostclassifier More on reddit.com
๐ŸŒ r/learnmachinelearning
7
66
December 16, 2021
Fuzzy matching

Go for fuzzywuzzy. It's easy to use and have an active community. ๐Ÿ˜‰

More on reddit.com
๐ŸŒ r/datascience
3
2
July 10, 2019
Top answer
1 of 4
147

There is a package called thefuzz. Install via pip:

pip install thefuzz

Simple usage:

>>> from thefuzz import fuzz
>>> fuzz.ratio("this is a test", "this is a test!")
    97

The package is built on top of difflib. Why not just use that, you ask? Apart from being a bit simpler, it has a number of different matching methods (like token order insensitivity, partial string matching) which make it more powerful in practice. The process.extract functions are especially useful: find the best matching strings and ratios from a set. From their readme:

Partial Ratio

>>> fuzz.partial_ratio("this is a test", "this is a test!")
    100

Token Sort Ratio

>>> fuzz.ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear")
    90
>>> fuzz.token_sort_ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear")
    100

Token Set Ratio

>>> fuzz.token_sort_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
    84
>>> fuzz.token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
    100

Process

>>> choices = ["Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys"]
>>> process.extract("new york jets", choices, limit=2)
    [('New York Jets', 100), ('New York Giants', 78)]
>>> process.extractOne("cowboys", choices)
    ("Dallas Cowboys", 90)
2 of 4
123

There is a module in the standard library (called difflib) that can compare strings and return a score based on their similarity. The SequenceMatcher class should do what you want.

Small example from Python prompt:

>>> from difflib import SequenceMatcher as SM
>>> s1 = ' It was a dark and stormy night. I was all alone sitting on a red chair. I was not completely alone as I had three cats.'
>>> s2 = ' It was a murky and stormy night. I was all alone sitting on a crimson chair. I was not completely alone as I had three felines.'
>>> SM(None, s1, s2).ratio()
0.9112903225806451
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ fuzzy matching or other alternativies?
r/learnpython on Reddit: Fuzzy Matching or Other Alternativies?
March 24, 2024 -

Hi,

My file contains a lot of garbage for the field name city

I'm trying to correct:

For example,

Correct: Los Angeles

Incorrect: Las Angelas

*Las Angelas is a typo. But, the tool will group them together to the correct one.

Second example:

Correct: Los Angeles@!#@!#

Incorrect: Los Angeles,CA

*I don't need to see ,CA there. Just the name of the city.

Third Example:

Correct: Edmonton

Incorrect: Edmonton Alberta

*I don't need to see Alberta there. Just the name of the city.

There are a lot of typos in my data and just wondering the quickest way to handle this and almost impossible to me to correct one by one. Thank you!

What should I do to handle this? should I use fuzzy matching or is there any other tool that is the best to handle this?

Top answer
1 of 5
7
Correct: Los Angeles@!#@!# Thant's correct? It's a difficult problem in general. One approach is to start with a list of known correct place names. Then probably a combination of approaches removing extraneous stuff that can't be part of the name, like punctuation, unicode, whatever possibly you may be able to remove tokens you know are wrong, by having a "known bad token" list, like Alberta, CA, TX etc Doing fuzzy matching from the "cleaned" string to the known good list. There's some description here: https://www.datacamp.com/tutorial/fuzzy-string-python I know there are a few "fuzzy string matchers" in python, I don't know a lot about any of them, but "thefuzz" seems to implement quite a few of the methods I know about. Note that there are some confounding factors. You can't just remove "CA" blindly because what if there's a now called "Cannibal" which would be "nnibal" if you removed the CA It's definitely not a trivial task and in the end I think you'll have to do a lot of "babysitting" and checking of the results.
2 of 5
1
Hi, My own Fuzzywuzzy experience tells me that only fuzzywuzzy will not do the task you want.(Short answer in last paragraph) ๐Ÿคญ I had/have a similar problem with identifying songs for a Spotify like continuous playlist-automation function. I use the function to create a radio like playlist obiding certain rules. The function needs to identify if a certain song obays certain rules. The database is continuously derived from several playlists which contains duplicate songs needed to compile a natural running playlist. But...Metadata can be a b*tch. Especially because every Api/playlist uses a slightly different format. There is no uniform format. For example the featured artist. It can be feat. Ft. Or featuring. Sometimes they use ' / ' , 'x ' , 'with' or even '&'... And it can be in the artist or title. Fuzzywuzzy alone won't do to filter this in most cases. At the start I used fuzzywuzzy to get a ratio between the songs. Setting the ratio low (for ex. 50) to determine if there is a match at all. After that i strip each word after using the ' - ' as split between title and artist or artist and title (the only consistent in the metadata of all services) and then search every word in the comparison song. Artists -> artist and artist --> title and the same for the obtained title. Giving each match a rating. If it passes the artist is added in the desired format to a list and the title to a seperate list. Also correcting the metadata of the songs as a whole.(While identifying the artist. Logically it then also identifies the title which it then converts to the desired format.) Nowadays i can fully rely the function to do it's task, be it after a lot of babysitting. My function can now identify similar songs for 99,9% and so identify/correct any differences in annotation of title, artists etc. Any new songs or artist will also be identified and added to the lists. Any mistakes by the function are also automatically corrected in later runs. Fuzzywuzzy can now be used in the function because the data is now uniform. Using only fuzzywuzzy didn't work for me as a standalone in the beginning. To identify an artist like Pink or P!nk will need a too low ratio (75) will result in a mismatch for too many songs. It now correctly identifies songs like where the title is Post Malone instead of the artist Post Malone regardless of the artist - title format. In short.... Use lists like suggested. Create a function that uses logical combinations to match and correct any misspelled data or incorrect combination. Next to fuzzywuzzy...
๐ŸŒ
GitHub
github.com โ€บ seatgeek โ€บ thefuzz
GitHub - seatgeek/thefuzz: Fuzzy String Matching in Python ยท GitHub
>>> fuzz.token_sort_ratio("fuzzy was a bear", "wuzzy fuzzy was a bear") 84 >>> fuzz.partial_token_sort_ratio("fuzzy was a bear", "wuzzy fuzzy was a bear") 100 ยท >>> choices = ["Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys"] >>> process.extract("new york jets", choices, limit=2) [('New York Jets', 100), ('New York Giants', 78)] >>> process.extractOne("cowboys", choices) ("Dallas Cowboys", 90) You can also pass additional parameters to extractOne method to make it use a specific scorer. A typical use case is to match file paths:
Starred by 3.6K users
Forked by 165 users
Languages ย  Python 90.8% | Shell 9.2%
๐ŸŒ
Boardflare
boardflare.com โ€บ posts โ€บ 2024 โ€บ fuzzy-matching-python-excel
Fuzzy Matching with Python in Excel | Boardflare - Private AI and automation for Excel
November 4, 2024 - Perform approximate string matching in Excel using the NLTK library and Python, enabling powerful fuzzy search capabilities beyond exact matches.
Find elsewhere
๐ŸŒ
Medium
medium.com โ€บ @bravekjh โ€บ unlocking-the-power-of-fuzzy-matching-in-python-a-practical-guide-ec37ebd8f3eb
Unlocking the Power of Fuzzy Matching in Python: A Practical Guide | by Jay Kim | Medium
June 26, 2025 - Gives more weight to matching characters near the start of the strings. Ideal for short strings like names. Uses vector space models and is often applied to token-based or character n-gram embeddings.
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ fuzzy-match
fuzzy-match ยท PyPI
Fuzzy string matching in Python. By default it uses Trigrams to calculate a similarity score and find matches by splitting strings into ngrams with a length of 3. The length of the ngram can be altered if desired.
      ยป pip install fuzzy-match
    
Published ย  Nov 13, 2020
Version ย  0.0.1
๐ŸŒ
Microsoft Community Hub
techcommunity.microsoft.com โ€บ microsoft community hub โ€บ communities โ€บ topics โ€บ education sector โ€บ educator developer blog
Whatโ€™s in a Name? Fuzzy Matching for Real-World Data | Microsoft Community Hub
October 21, 2025 - Thatโ€™s where fuzzy matching comes in, using a variety of techniques we can rank how similar different non-identical words are to try and find the most likely match. But the question is, what fuzzy matching algorithms are best suited for matching what types of data? And can generative AI play a part in this matching game? ... TextDistance and Python-Levenshtein โ€“ classic edit-distance approaches.
๐ŸŒ
Medium
medium.com โ€บ @riat06 โ€บ fuzzy-logic-pythons-secret-to-string-matching-4091144b9316
Fuzzy Logic: Pythonโ€™s Secret to String Matching - Ria Thomas - Medium
August 30, 2024 - This is a short article โ€” a really short one โ€” on fuzzy string matching. Anyone who has worked with a large amount of data knows how frustrating it can get while trying to combine two datasets using a string key. The key can have certain words abbreviated or misspelled or even have a few extra blanks. I had found this useful library in Python a few years ago when I was looking for a better way to match strings partially for a similar client request.
๐ŸŒ
Built In
builtin.com โ€บ data-science โ€บ fuzzy-matching-python
Fuzzy String Matching in Python: Intro to Fuzzywuzzy | Built In
Summary: Fuzzy string matching is the process of determining whether two strings approximately match each other. It uses the Levenshtein distance to calculate the number of steps needed to transform one string into another.
๐ŸŒ
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 - In this tutorial, we will learn how to do fuzzy matching on the pandas DataFrame column using Python. Fuzzy matching is a process that lets us identify the matches which are not exact but find a given pattern in our target item. Fuzzy matching ...
๐ŸŒ
Getflookup
getflookup.com โ€บ blog โ€บ python-data-cleaning-fuzzy-matching
Python Data Cleaning and Fuzzy Matching Guide | Flookup Data Wrangler Blog
November 1, 2025 - Fuzzy matching, also known as approximate string matching, is a technique used to identify text strings that are approximately, rather than exactly, the same. This is incredibly useful for tasks like deduplication, record linkage and correcting ...
๐ŸŒ
Medium
medium.com โ€บ codex โ€บ best-libraries-for-fuzzy-matching-in-python-cbb3e0ef87dd
Best Libraries for Fuzzy Matching In Python | by Moosa Ali | CodeX | Medium
August 15, 2022 - RapidFuzz also offers more functionality, similar to FuzzyWuzzy. Read more about them in the official documentation. ... The Jaro-Winkler distance also has multiple implementations in python, but apparently, many of those are incorrect. According to one user on StackOverflow, the results produced by pyjarowinkler, a very old and popular python library, seem incorrect. I tested the same problem with the jaro-winkler library and got matching results to other correct implementations.
๐ŸŒ
CodeSpeedy
codespeedy.com โ€บ home โ€บ fuzzy string matching in python
Fuzzy String Matching in Python - CodeSpeedy
August 28, 2019 - Spell check, DNA matching, spam filtering, etc. Thus, we have learnt how to determine similarity between two strings and to extract the most similar from the available options. In the process, we learnt about Fuzzywuzzy library, itโ€™s modules-fuzz and process.
๐ŸŒ
Medium
medium.com โ€บ @yachna398 โ€บ natural-language-processing-for-fuzzy-string-matching-with-python-c66d52fab0e0
Natural Language Processing for Fuzzy String Matching with Python | by Yachna Hasija | Medium
December 30, 2025 - FuzzyWuzzy is a Python library uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package. There are four popular types of fuzzy matching logic supported by fuzzywuzzy package:
๐ŸŒ
Towards Data Science
towardsdatascience.com โ€บ home โ€บ latest โ€บ fuzzy string matching โ€“ how to match strings that arenโ€™t identical
Fuzzy String Matching - How To Match Strings That Aren't Identical | Towards Data Science
March 5, 2025 - Str1 = "FC Barcelona" Str2 = "The victory went to FC Barcelona " Token_Set_Ratio = fuzz.token_set_ratio(Str1,Str2) To me, this is the most useful part. You could calculate a score for all of the potential matches and then chose the largest โ€“ or just let FW do it for you.
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ fuzzywuzzy
fuzzywuzzy ยท PyPI
It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package. ... python-Levenshtein (optional, provides a 4-10x speedup in String Matching, though may result in differing results for certain cases)
      ยป pip install fuzzywuzzy
    
Published ย  Feb 13, 2020
Version ย  0.18.0
๐ŸŒ
Plagiarism Detector
plagiarismdetector.net
Plagiarism Checker Free | MOST Accurate with Percentage โœ…
Phrases or sentences shown in the results below are the ones that our plagiarism detector has identified as plagiarized and already exist online, along with the matched percentage. These are the links and by clicking on the โ€œMatch Textโ€ you will be redirected to the original source where you can see yourself the plagiarized text.