Polars Fuzzy
Fast fuzzy string matching for Polars DataFrames, powered by Rust.
Installation
pip install polars-fuzzy
Quick Start
import polars as pl
import polars_fuzzy as pf
df = pl.DataFrame({"name": ["John Smith", "Jane Doe", "Benjamin", "Johnny", None]})
# Raw fuzzy score - higher is better, null means no match
print(df.with_columns(pf.fuzzy_score("name", "john").alias("score")))
# ┌────────────┬───────┐
# │ name ┆ score │
# │ --- ┆ --- │
# │ str ┆ u32 │
# ╞════════════╪═══════╡
# │ John Smith ┆ 114 │
# │ Jane Doe ┆ null │
# │ Benjamin ┆ null │
# │ Johnny ┆ 114 │
# │ null ┆ null │
# └────────────┴───────┘
# Normalized score - 0.0 to 1.0, easier to threshold
print(df.with_columns(pf.fuzzy_score_normalized("name", "john").alias("score")))
# Filter - only rows that match
print(df.filter(pf.fuzzy_score("name", "john").is_not_null()))
# Sort by best match
print(
df.with_columns(pf.fuzzy_score("name", "john").alias("score")).sort(
"score", descending=True, nulls_last=True
)
)
Column vs Column
Useful for record linkage - matching names across two datasets.
customers = pl.DataFrame({"name": ["John Smith", "Jane Doe"]})
invoices = pl.DataFrame({"client": ["Jon Smith", "J. Doe"]})
customers.join(invoices, how="cross").with_columns(
pf.fuzzy_score_normalized("name", "client").alias("score")
).filter(pl.col("score").is_not_null()).sort("score", descending=True)
Fuzzy JOIN
result = pf.fuzzy_join(
customers, invoices,
left_on="name",
right_on="client",
threshold=0.8,
)
Options
pf.fuzzy_score(
"name", # haystack - column name or pl.Expr
"john", # query - string literal, column name, or pl.Expr
case_sensitive=False, # default: False
normalize=True, # accent folding: "café" matches "cafe"
)
Performance
- Zero heap allocations in the per-row hot loop
- Literal patterns compiled once per column, not per row
- Nulls propagated without entering the matcher
- Backed by Nucleo - the fuzzy engine powering the Helix editor
License
MIT
Metadata
Release files for polars-fuzzy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polars_fuzzy-0.1.1.tar.gz | 28.2 kB | Without provenance | Details for polars_fuzzy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polars_fuzzy-0.1.1-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for polars_fuzzy-0.1.1-cp39-abi3-macosx_11_0_arm64.whl |
Total release size: 4.0 MB
Release files / polars_fuzzy-0.1.1.tar.gz
| Download URL | polars_fuzzy-0.1.1.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67c405891455790d55fc7859caf51db729a6bf65d4920df366081c01ee2464ff
|
|
BLAKE2b-256 checksum How to use checksums |
0f0a4b7190beab8d55a913fc2b1599d457119ccc59e5c78e1d98e2a82cc7716c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|
Release files / polars_fuzzy-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | polars_fuzzy-0.1.1-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.9 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ab536f40f809b34cc7b83ff5c07eea5a1b67bbfeaf1c002d9cc124b032703bb8
|
|
BLAKE2b-256 checksum How to use checksums |
1f7b61c62b67c7d7d67367f1bce6456e2c0737650127bea2668b76e870529d86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|
Security for polars-fuzzy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.