Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ion-elgreco/polars-distance
Polars plugin for pairwise distance functions
https://github.com/ion-elgreco/polars-distance
Last synced: 3 days ago
JSON representation
Polars plugin for pairwise distance functions
- Host: GitHub
- URL: https://github.com/ion-elgreco/polars-distance
- Owner: ion-elgreco
- License: mit
- Created: 2023-11-04T23:27:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-19T08:42:14.000Z (about 1 month ago)
- Last Synced: 2025-01-12T13:06:42.446Z (10 days ago)
- Language: Rust
- Homepage: https://ion-elgreco.github.io/polars-distance/
- Size: 700 KB
- Stars: 55
- Watchers: 1
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-polars - polars-distance - Polars plugin for pairwise distance functions by [@ion-elgreco](https://github.com/ion-elgreco). (Libraries/Packages/Scripts / Polars plugins)
README
This plugin provides distance metrics on list, arrays and string datatypes in polars.
The docs can be found here: https://ion-elgreco.github.io/polars-distance/
## Examples
```python
import polars as pl
import polars_distance as plddf = pl.DataFrame({
"foo":"hello",
"bar":"hella world"
})df.select(
pld.col("foo").dist_str.hamming('bar').alias('dist')
)
┌──────┐
│ dist │
│ --- │
│ u32 │
╞══════╡
│ 7 │
└──────┘df.select(
pld.col('foo').dist_str.levenshtein('bar').alias('dist')
)
┌──────┐
│ dist │
│ --- │
│ u32 │
╞══════╡
│ 6 │
└──────┘df = pl.DataFrame(
{
"arr": [[1, 2, 10]],
"arr2": [[2, 5, 9]],
},
schema={
"arr": pl.Array(inner=pl.Float64, width=3),
"arr2": pl.Array(inner=pl.Float64, width=3),
},
)
df.select(pld.col('arr').dist_arr.euclidean('arr2').alias('dist'))
shape: (1, 1)
┌──────────┐
│ dist │
│ --- │
│ f64 │
╞══════════╡
│ 3.316625 │
└──────────┘
```