跳转到主要内容

Polars的稳定非加密和加密哈希函数

项目描述

此插件提供跨不同polars版本的稳定哈希功能。

示例

加密哈希器

import polars
import polars_hash as plh

df = pl.DataFrame({
    "foo":["hello_world"]
})

result = df.select(plh.col('foo').chash.sha256())

print(result)

┌──────────────────────────────────────────────────────────────────┐
 foo                                                              
 ---                                                              
 str                                                              
╞══════════════════════════════════════════════════════════════════╡
 35072c1ae546350e0bfa7ab11d49dc6f129e72ccd57ec7eb671225bbd197c8f1 
└──────────────────────────────────────────────────────────────────┘

非加密哈希器

df = pl.DataFrame({
    "foo":["hello_world"]
})

result = df.select(plh.col('foo').nchash.wyhash())
print(result)
┌──────────────────────┐
 foo                  
 ---                  
 u64                  
╞══════════════════════╡
 16737367591072095403 
└──────────────────────┘

地理哈希器

df = pl.DataFrame(
    {"coord": [{"longitude": -120.6623, "latitude": 35.3003}]},
    schema={
        "coord": pl.Struct(
            [pl.Field("longitude", pl.Float64), pl.Field("latitude", pl.Float64)]
        ),
    },
)

df.with_columns(
    plh.col('coord').geohash.from_coords().alias('geohash')
)
shape: (1, 2)
┌─────────────────────┬────────────┐
 coord                geohash    
 ---                  ---        
 struct[2]            str        
╞═════════════════════╪════════════╡
 {-120.6623,35.3003}  9q60y60rhs 
└─────────────────────┴────────────┘


pl.select(pl.lit('9q60y60rhs').geohash.to_coords().alias('coordinates'))
shape: (1, 1)
┌───────────────────────┐
 coordinates           
 ---                   
 struct[2]             
╞═══════════════════════╡
 {-120.6623,35.300298} 
└───────────────────────┘

从多个列创建哈希

df = pl.DataFrame({
    "foo":["hello_world"],
    "bar": ["today"]
})

result = df.select(plh.concat_str('foo','bar').chash.sha256())

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

polars_hash-0.4.8.tar.gz (22.1 kB 查看哈希)

上传时间:

构建分布

polars_hash-0.4.8-cp38-abi3-win_amd64.whl (3.1 MB 查看哈希)

上传于 CPython 3.8+ Windows x86-64

polars_hash-0.4.8-cp38-abi3-win32.whl (2.7 MB 查看哈希值)

上传于 CPython 3.8+ Windows x86

polars_hash-0.4.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB 查看哈希值)

上传于 CPython 3.8+ manylinux: glibc 2.17+ x86-64

polars_hash-0.4.8-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (7.1 MB 查看哈希值)

上传于 CPython 3.8+ manylinux: glibc 2.17+ s390x

polars_hash-0.4.8-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (9.5 MB 查看哈希值)

上传于 CPython 3.8+ manylinux: glibc 2.17+ ppc64le

polars_hash-0.4.8-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (6.9 MB 查看哈希值)

上传于 CPython 3.8+ manylinux: glibc 2.17+ i686

polars_hash-0.4.8-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (6.1 MB 查看哈希值)

上传于 CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

polars_hash-0.4.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.1 MB 查看哈希值)

上传于 CPython 3.8+ manylinux: glibc 2.17+ ARM64

polars_hash-0.4.8-cp38-abi3-macosx_11_0_arm64.whl (3.1 MB 查看哈希值)

上传于 CPython 3.8+ macOS 11.0+ ARM64

polars_hash-0.4.8-cp38-abi3-macosx_10_12_x86_64.whl (3.3 MB 查看哈希值)

上传于 CPython 3.8+ macOS 10.12+ x86-64

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面