"Acme Inc.", "ACME Incorporated" and "Acme Corp" are the same company. An exact match on the name column treats them as three. This post shows how to find those duplicates in Python with two string-similarity measures, and why normalizing the names first matters more than which measure you pick.

All scores below come from running the code, using pip install rapidfuzz.

Two measures

Levenshtein counts the edits (insert, delete, replace a character) needed to turn one string into the other. The normalized similarity is between 0 and 1.

Jaro-Winkler looks at matching characters and transpositions, and gives extra weight to a shared prefix. That suits names, where the start is usually typed correctly.

from rapidfuzz.distance import Levenshtein, JaroWinkler def scores(a, b): a, b = a.lower(), b.lower() return (round(Levenshtein.normalized_similarity(a, b), 2), round(JaroWinkler.similarity(a, b), 2)) 
A B Levenshtein Jaro-Winkler
Acme Inc. ACME Incorporated 0.47 0.87
Microsoft Corporation Microsoft 0.43 0.89
Jon Smith John Smith 0.90 0.97
Datablist Datalist 0.89 0.98
Stripe Strip Clubs Ltd 0.33 0.83

Two problems show up right away. Real duplicates ("Acme Inc." and "ACME Incorporated") score low on Levenshtein because the legal suffix adds a lot of characters. And two different companies ("Datablist" and "Datalist") score 0.98 on Jaro-Winkler, higher than any real duplicate in the table.

Normalize first

Most of the noise in company names is case, punctuation and legal suffixes. Remove them before comparing:

import re SUFFIXES = {"inc", "incorporated", "llc", "ltd", "limited", "gmbh", "sas", "sa", "corp", "corporation", "co", "company"} def normalize(name): name = re.sub(r"[^\w\s]", " ", name.lower()) return " ".join(w for w in name.split() if w not in SUFFIXES) 

After normalization, "Acme Inc." and "ACME Incorporated" both become acme (score 1.00), and "Microsoft Corporation" becomes microsoft (1.00). Exact matching on the normalized name already catches these, with no fuzzy step at all.

Then group what is still close

Fuzzy matching is for what normalization cannot fix: typos and small spelling differences. Compare every pair, and merge pairs above a threshold into groups with a small union-find:

def group(names, threshold=0.92): norm = [normalize(n) for n in names] parent = list(range(len(names))) def find(i): while parent[i] != i: parent[i] = parent[parent[i]] i = parent[i] return i for i in range(len(names)): for j in range(i + 1, len(names)): if JaroWinkler.similarity(norm[i], norm[j]) >= threshold: parent[find(j)] = find(i) groups = {} for i, n in enumerate(names): groups.setdefault(find(i), []).append(n) return list(groups.values()) print(group(["Acme Inc.", "ACME Incorporated", "Acme Corp", "Globex LLC", "Globex Corporation", "Initech", "Inittech Ltd", "Umbrella GmbH"])) 

Output:

[['Acme Inc.', 'ACME Incorporated', 'Acme Corp'], ['Globex LLC', 'Globex Corporation'], ['Initech', 'Inittech Ltd'], ['Umbrella GmbH']] 

Things that bite in real data

  • Short names collide. "Datablist" and "Datalist" are different companies. Use a second signal before merging: same domain, same country, or same LinkedIn page.
  • Pairwise comparison is O(n²). Fine for a few thousand rows. For more, compare only within blocks, for example names that share their first three characters or the same domain.
  • Pick the threshold on your own data. Label 50 pairs by hand and see where real duplicates and false matches separate.
  • Never auto-merge without review on data that matters. Flag groups, then decide which record keeps which fields.

If you would rather not maintain this code, Datablist runs the same kind of normalization and fuzzy matching on CSV files in the browser for free: datablist.com/learn/data-cleaning/fuzzy-matching.