Registry / data / polars-distance

polars-distance

JSON →
library0.5.3pypypi✓ verified 88d ago

Polars plugin for pairwise distance functions. Version 0.5.3 supports f32 and uint64 types. Release cadence is irregular, with minor/patch releases every few months.

pip install polars-distance
INSTALL
IMPORT
SIG · POLARS-DISTANCE
P
polars-distance
datapythonv0.5.3
Install
3.6s avg
Import
406ms
Disk
229MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.5.3 · 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.10–3.95 runs
build_error
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.6s · import 0.406s · 244MB
229MB installed
● package 229MB
Code
Verified usage

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

col
✓ import polars_distance as pld
✗ import polars_distance.polars as pld
The correct import is just the root module; no subpackage.

Compute pairwise Euclidean distance between list columns 'a' and 'b'.

import polars as pl import polars_distance as pld df = pl.DataFrame({ "a": [[1.0, 2.0], [3.0, 4.0]], "b": [[1.5, 2.5], [3.5, 4.5]] }) df.with_columns( dist=pld.col("a").pairwise_euclidean(pld.col("b")) )
Debug
Known issues
breakingVersion 0.3.2 removed categorical dtype support. If you rely on categorical columns in list/set distances, upgrade with caution.
fix
Convert categorical columns to string or numeric types before applying distance functions.
affects: >=0.3.2
deprecatedThe package previously allowed direct import of distance functions from polars_distance.polars. As of 0.5.0, the recommended import is the root module.
fix
Change imports to `import polars_distance as pld` and use `pld.col(...).pairwise_*`.
affects: <0.5.0
gotchapolars-distance requires Polars >= 0.20.0 and uses Polars plugins API. Incompatible with older Polars versions.
fix
Ensure Polars is updated: `pip install polars>=0.20.0`.
affects: all
Errors
Common errors & fixes
AttributeError: module 'polars_distance' has no attribute 'pairwise_euclidean'
Attempting to call the distance function as a top-level module attribute instead of using the expression API.
fix
Use `pld.col('a').pairwise_euclidean(pld.col('b'))` inside `df.with_columns()` or similar.
polars.exceptions.ComputeError: ... dtype is not supported
Passing a column with an unsupported dtype (e.g., categorical) to a distance function.
fix
Cast the column to a supported dtype: `df.with_columns(pl.col('col').cast(pl.Utf8))`.
Upgrade
Version history
0.5.3latest on PyPI · released Apr 20, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
20
Bingbot
1
Resources
polars-distance — pip install polars-distance · libregistry