top of page
  • Writer's pictureWill Austell

Clear Views Ahead - Enhancing Data Integrity with Fuzzy Matching

Author: Will Austell

Clear Views Ahead - Enhancing Data Integrity with Fuzzy Matching

When it comes to Customer Relationship Management (CRM) systems, maintaining data integrity is paramount. However, even with robust structures in place, challenges arise, such as the existence of orphan records.

Stay with us as we delve into a practical solution based on a real client’s scenario using Python and SQL within a CRM's account module.

The Challenge: Orphan Ship-To Accounts

Interloop is working with a client that has a CRM system where accounts are categorized into Bill-To and Ship-To accounts, forming a parent-child hierarchy. Ideally, Ship-To accounts should always have a corresponding Bill-To parent. However, orphan Ship-To records, those without a Bill-To parent, can occur due to system limitations or human error.

The Solution: Fuzzy Address Matching

To address this challenge, Interloop proposed a solution leveraging Python's rapidfuzz library for fuzzy string matching and SQL for data manipulation to connect these orphan Ship-To records to an existing Bill-To parent record based on address matches.

We will be working in a Spark notebook in Microsoft Fabric. Here's how it works:

1. Installing and Setting Up RapidFuzz

First, we install the Rapidfuzz library, a powerful tool for string matching and similarity measurement, via pip.

2. Data Retrieval and Preparation

We retrieve relevant data from the CRM database using SQL queries, focusing on Ship-To and Bill-To accounts within a specific region (e.g., EDOH in this example). These queries yield dataframes in a Spark environment, which we subsequently convert to Pandas dataframes for local processing.

3. Address Normalization

Before comparison, we normalize the addresses of both Ship-To and Bill-To accounts by concatenating relevant address fields and applying lowercase conversion, stripping, and removal of non-alphanumeric characters. This step ensures uniformity for accurate matching.

4. Fuzzy Matching

Using RapidFuzz, we iterate through each Ship-To and Bill-To pair, calculating a similarity score based on their normalized addresses. A threshold of 87% is set to consider matches, ensuring a balance between precision and inclusivity. The score threshold will vary and can be calibrated to meet your specific string-matching needs. In our example, we found the sweet spot was around 87% for optimal address matching.

5. Storing Matched Results

Fuzzy matched results are stored in a delta table, preserving essential details such as IDs, account types, and dates entered. This structured storage facilitates further analysis and action.

6. Selecting Optimal Matches

To mitigate redundancy, we select the highest scoring match for each Ship-To account, discarding lower-scoring alternatives. This step ensures the accuracy and efficiency of the matching process.


Incorporating fuzzy address matching into CRM data management workflows offers a pragmatic approach to address integrity challenges. By leveraging Python's rapidfuzz library and SQL for data manipulation, organizations can enhance the accuracy and completeness of their account records, thereby improving decision-making and customer service.

In summary, through the integration of advanced matching techniques, the vision of a harmonized CRM dataset—free from orphan records—is within reach, ushering in a new era of data integrity and operational efficiency.


Looking for clear, practical solutions to your data challenges? Let’s loop you in. Book your intro call with our data experts today.



התגובות הושבתו לפוסט הזה.
bottom of page