Fuzzy merging and matching utilities for pandas Dataframes.
Project description
fuzzy-df
fuzzy-df is a Python package that provides utilities for performing fuzzy matching and merging on pandas DataFrames and Series. It leverages the power of rapidfuzz for efficient similarity computations and integrates seamlessly with pandas.
Features
- Fuzzy Matching: Match elements between two pandas Series based on similarity scores.
- Fuzzy Merging: Merge pandas DataFrames or Series using fuzzy matching logic.
- Customizable: Configure similarity score thresholds and specify custom column names for scores.
Installation
You can install fuzzy-df using pip:
pip install fuzzy-df
Usage
Fuzzy Matching
Use the fuzz_match function to perform fuzzy matching between two pandas Series:
import pandas as pd
from fuzzy_df.match import fuzz_match
comp_left = pd.Series(["apple", "banana", "cherry"])
comp_right = pd.Series(["apples", "grape", "bananas", "apple"])
matches = fuzz_match(comp_left, comp_right, score_cutoff=70)
print(matches)
Output:
left_index right_index score
0 0 0 90.909088
1 0 3 100.000000
2 1 2 92.307693
Fuzzy Merging
Use the fuzz_merge function to merge two pandas DataFrames or Series based on fuzzy matching:
import pandas as pd
from fuzzy_df.merge import fuzz_merge
left = pd.DataFrame(
{"id_left": [1, 2], "name_left": ["foo", "bar"]})
right = pd.DataFrame(
{"id_right": [3, 4, 5, 6], "name_right": ["baz", "bear", "fool", "food"]})
merged = fuzz_merge(left, right, left_on="name_left",
right_on="name_right", score_cutoff=70)
print(merged)
Output:
id_right name_right id_left name_left left_index right_index score
2 4 bear 2 bar 1 1 85.714287
0 5 fool 1 foo 0 2 85.714287
1 6 food 1 foo 0 3 85.714287
Building
Building with uv
To build the project using uv, follow these steps:
-
Setup python version: Overide the .python-version to test out on supported python version
>=3.10:echo 3.13 > .python-version
-
Run the build command: Navigate to the project directory and execute the following command:
uv buildThis will package the project and prepare it for distribution.
-
Verify the build: After the build process completes, you should see the generated distribution files in the
dist/directory. You can verify them by listing the contents:ls dist/ -
Install the built package locally (optional): To test the built package, you can install it locally using pip:
pip install dist/fuzzy_df-<version>.tar.gz
Replace <version> with the actual version number of the package.
For more information on uv, refer to its documentation.
Testing
To run tests, follow these steps:
-
Install the package in editable mode:
uv pip install -e .
-
Run the test suite using
pytest:uv run pytest
This will execute all the tests and display the results in the terminal.
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Developed by Iman-Budi Pranakasih. For inquiries, contact ibpranakasih@gmail.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fuzzy_df-0.1.1.tar.gz.
File metadata
- Download URL: fuzzy_df-0.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c542b41d05464723108444a96a8625b0ba507f7570578c0d9e760269a9fd76cc
|
|
| MD5 |
aa654c47944f867be52a145a52ce82bf
|
|
| BLAKE2b-256 |
a71521d07f3756342727f5534bbe638f103ab02f46b656fc03bb828f4dfcd3ab
|
Provenance
The following attestation bundles were made for fuzzy_df-0.1.1.tar.gz:
Publisher:
release.yml on ibpme/fuzzy-df
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fuzzy_df-0.1.1.tar.gz -
Subject digest:
c542b41d05464723108444a96a8625b0ba507f7570578c0d9e760269a9fd76cc - Sigstore transparency entry: 188584886
- Sigstore integration time:
-
Permalink:
ibpme/fuzzy-df@0087b604540f857acb706980a1ffa4b888068065 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ibpme
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0087b604540f857acb706980a1ffa4b888068065 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fuzzy_df-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fuzzy_df-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05cf1a84ee813e05e772605d8930928f3a8fcdfe3de069034db5ecae1fe935f0
|
|
| MD5 |
a65d556e718ead6db59f8c680da0a511
|
|
| BLAKE2b-256 |
4cf3928e53d33bc1a0323004061cd73799a7639bc27dde05039726fb829753f3
|
Provenance
The following attestation bundles were made for fuzzy_df-0.1.1-py3-none-any.whl:
Publisher:
release.yml on ibpme/fuzzy-df
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fuzzy_df-0.1.1-py3-none-any.whl -
Subject digest:
05cf1a84ee813e05e772605d8930928f3a8fcdfe3de069034db5ecae1fe935f0 - Sigstore transparency entry: 188584891
- Sigstore integration time:
-
Permalink:
ibpme/fuzzy-df@0087b604540f857acb706980a1ffa4b888068065 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ibpme
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0087b604540f857acb706980a1ffa4b888068065 -
Trigger Event:
push
-
Statement type: