Skip to main content

Polars plugin for pairwise distance functions

Project description

Hellooo :)

This plugin is a work-in progress, main goal is to provide distance metrics on list, arrays and string datatypes.

The docs can be found here: https://ion-elgreco.github.io/polars-distance/

Examples

import polars
import polars_distance as pld

df = 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 
└──────────┘

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polars_distance-0.4.3.tar.gz (22.7 kB view hashes)

Uploaded Source

Built Distributions

polars_distance-0.4.3-cp38-abi3-win_amd64.whl (4.4 MB view hashes)

Uploaded CPython 3.8+ Windows x86-64

polars_distance-0.4.3-cp38-abi3-win32.whl (4.0 MB view hashes)

Uploaded CPython 3.8+ Windows x86

polars_distance-0.4.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

polars_distance-0.4.3-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (10.7 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ s390x

polars_distance-0.4.3-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (7.0 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ppc64le

polars_distance-0.4.3-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (7.3 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686

polars_distance-0.4.3-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (6.7 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

polars_distance-0.4.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.5 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

polars_distance-0.4.3-cp38-abi3-macosx_11_0_arm64.whl (4.4 MB view hashes)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_distance-0.4.3-cp38-abi3-macosx_10_12_x86_64.whl (4.9 MB view hashes)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page