Registry / data / recordlinkage

recordlinkage

JSON →
library0.16pypypi✓ verified 26d ago

RecordLinkage is a powerful and modular Python toolkit for record linkage and duplicate detection. It provides methods for indexing, comparing records with various similarity measures, and classifying matches, leveraging pandas and numpy for efficient data handling. The library is actively maintained (version 0.16) and suitable for research and linking small to medium-sized datasets.

pip install recordlinkage
INSTALL
IMPORT
SIG · RECORDLINKAGE
R
recordlinkage
datapythonv0.16
Install
15.1s avg
Import
4291ms
Disk
382MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.16 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 15.1s · import 4.291s · 362MB
382MB installed
● package 382MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

recordlinkage
import recordlinkage
Main module import.
Index
from recordlinkage import Index
To create an indexer object.
Block
from recordlinkage.index import Block
Direct import for specific indexing algorithms.
Compare
from recordlinkage import Compare
To create a comparator object.
Exact
from recordlinkage.compare import Exact
Direct import for specific comparison measures.

This quickstart demonstrates the core steps of record linkage: generating candidate pairs using blocking on a common attribute (city/town), comparing these pairs using string similarity and exact matches, and then classifying likely matches based on the comparison scores.

import recordlinkage import pandas as pd # Dummy data for demonstration df_a = pd.DataFrame({ 'name': ['John Doe', 'Jane Smith', 'Peter Jones'], 'city': ['New York', 'Los Angeles', 'Chicago'] }, index=['id_a_1', 'id_a_2', 'id_a_3']) df_b = pd.DataFrame({ 'full_name': ['Jon Doe', 'Jane Smiht', 'Pete Jones'], 'town': ['New York', 'Los Angles', 'Chicago'] }, index=['id_b_1', 'id_b_2', 'id_b_3']) # 1. Indexing: Generate candidate links using blocking indexer = recordlinkage.Index() indexer.block(left_on='city', right_on='town') candidate_links = indexer.index(df_a, df_b) print(f'Generated {len(candidate_links)} candidate links.') # 2. Comparing: Compare records on relevant attributes compare_cl = recordlinkage.Compare() compare_cl.string('name', 'full_name', method='jarowinkler', label='name_similarity') compare_cl.exact('city', 'town', label='city_exact') features = compare_cl.compute(candidate_links, df_a, df_b) # 3. Classification: Decide on matches based on comparison features # Simple sum of scores (1 for match, 0 for mismatch) matches = features[features.sum(axis=1) > 1.5] print('\nIdentified Matches:') print(matches.index.to_list())
Debug
Known issues
breakingVersion 0.15 removed several deprecated classes and bumped the minimum required Python version to 3.8 and pandas version to >=1.0. Older code using removed classes or incompatible Python/pandas versions will break.
fix
Review the release notes for version 0.15 to update deprecated class usages and ensure your environment meets the new minimum Python (3.8+) and pandas (1.0+) requirements.
affects: >=0.15
gotchaThe choice of blocking keys can introduce significant bias, as true matches that do not share the exact same blocking key will be missed. This is especially problematic with data entry errors or variations.
fix
Carefully select blocking keys, considering multiple keys (union of blocks), using more error-tolerant indexing methods (e.g., sorted neighbourhood, phonetic blocking), or applying pre-processing to standardize blocking fields.
affects: All
gotchaString comparison performance varies greatly between algorithms. Highly accurate but computationally intensive algorithms like Damerau-Levenshtein can be much slower than Jaro-Winkler or Jaro, especially on large datasets. Ensure the 'jellyfish' library (Rust version) is correctly installed for optimal string comparison speed.
fix
Benchmark different string comparison methods for your specific data and choose a balance between accuracy and performance. Prioritize 'jellyfish' for string comparisons and ensure the Rust-backed version is active (check `import jellyfish.rustyfish` does not raise an exception).
affects: All
gotchaEffective record linkage heavily depends on prior data cleaning and standardization. Inconsistent formatting, typos, missing values, or variations in how information is recorded (e.g., 'St.' vs 'Street') can severely hinder matching accuracy.
fix
Implement robust pre-processing steps using `recordlinkage.standardise` or other data cleaning libraries to normalize names, addresses, dates, and other attributes before attempting to link records.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'recordlinkage'
The 'recordlinkage' package is not installed in your Python environment.
fix
pip install recordlinkage
AttributeError: module 'recordlinkage' has no attribute 'Block'
Classes like 'Block', 'SortedNeighbourhood', 'String', etc., are located within specific submodules (e.g., `recordlinkage.index`, `recordlinkage.compare`) and cannot be accessed directly from the top-level 'recordlinkage' package.
fix
Import the class from its correct submodule, for example: `from recordlinkage.index import Block` or `from recordlinkage.compare import String`.
ValueError: The method 'wrong_method' is not a valid comparison method.
An unsupported or misspelled method name was provided for a string comparison function (e.g., in `compare.string` or `compare.String`).
fix
Use a valid string comparison method name, such as 'jarowinkler', 'levenshtein', 'damerau_levenshtein', 'jaro', 'exact', 'qgram', 'cosine', or 'smith_waterman'.
Upgrade
Version history
0.16latest on PyPI · released Jul 20, 2023
Audit
Dependencies
numpyrequiredCore numerical operations.
pandasrequiredPrimary data handling and manipulation.
scipyrequiredScientific computing functionalities.
sklearnrequiredMachine learning algorithms for classification.
jellyfishrequiredOptimized string comparison algorithms.
joblibrequiredParallel computing and caching.
numexproptionalAccelerating numerical operations (recommended for performance).
bottleneckoptionalAccelerating NaN evaluations (recommended for performance).
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
recordlinkage — pip install recordlinkage · libregistry