{"id":21698,"library":"polars-distance","title":"polars-distance","description":"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.","status":"active","version":"0.5.3","language":"python","source_language":"en","source_url":"https://github.com/ion-elgreco/polars-distance","tags":["polars","distance","plugin","pairwise"],"install":[{"cmd":"pip install polars-distance","lang":"bash","label":"pip"}],"dependencies":[],"imports":[{"note":"The correct import is just the root module; no subpackage.","wrong":"import polars_distance.polars as pld","symbol":"col","correct":"import polars_distance as pld"}],"quickstart":{"code":"import polars as pl\nimport polars_distance as pld\n\ndf = pl.DataFrame({\n    \"a\": [[1.0, 2.0], [3.0, 4.0]],\n    \"b\": [[1.5, 2.5], [3.5, 4.5]]\n})\ndf.with_columns(\n    dist=pld.col(\"a\").pairwise_euclidean(pld.col(\"b\"))\n)","lang":"python","description":"Compute pairwise Euclidean distance between list columns 'a' and 'b'."},"warnings":[{"fix":"Convert categorical columns to string or numeric types before applying distance functions.","message":"Version 0.3.2 removed categorical dtype support. If you rely on categorical columns in list/set distances, upgrade with caution.","severity":"breaking","affected_versions":">=0.3.2"},{"fix":"Change imports to `import polars_distance as pld` and use `pld.col(...).pairwise_*`.","message":"The package previously allowed direct import of distance functions from polars_distance.polars. As of 0.5.0, the recommended import is the root module.","severity":"deprecated","affected_versions":"<0.5.0"},{"fix":"Ensure Polars is updated: `pip install polars>=0.20.0`.","message":"polars-distance requires Polars >= 0.20.0 and uses Polars plugins API. Incompatible with older Polars versions.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `pld.col('a').pairwise_euclidean(pld.col('b'))` inside `df.with_columns()` or similar.","cause":"Attempting to call the distance function as a top-level module attribute instead of using the expression API.","error":"AttributeError: module 'polars_distance' has no attribute 'pairwise_euclidean'"},{"fix":"Cast the column to a supported dtype: `df.with_columns(pl.col('col').cast(pl.Utf8))`.","cause":"Passing a column with an unsupported dtype (e.g., categorical) to a distance function.","error":"polars.exceptions.ComputeError: ... dtype is not supported"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}