Skip to content

Hash elements

Source code

Description

The hash value is of type UInt64.

Usage

<Expr>$hash(seed = 0, seed_1 = NULL, seed_2 = NULL, seed_3 = NULL)

Arguments

seed Random seed parameter. Defaults to 0. Doesn’t have any effect for now.
seed_1, seed_2, seed_3 Random seed parameter. Defaults to arg seed. The column will be coerced to UInt32.

Value

Expr

Examples

library("polars")

df = pl$DataFrame(iris[1:3, c(1, 2)])
df$with_columns(pl$all()$hash(1234)$name$suffix("_hash"))
#> shape: (3, 4)
#> ┌──────────────┬─────────────┬─────────────────────┬─────────────────────┐
#> │ Sepal.Length ┆ Sepal.Width ┆ Sepal.Length_hash   ┆ Sepal.Width_hash    │
#> │ ---          ┆ ---         ┆ ---                 ┆ ---                 │
#> │ f64          ┆ f64         ┆ u64                 ┆ u64                 │
#> ╞══════════════╪═════════════╪═════════════════════╪═════════════════════╡
#> │ 5.1          ┆ 3.5         ┆ 9871625582493124596 ┆ 3085175659021231231 │
#> │ 4.9          ┆ 3.0         ┆ 8635986628266650833 ┆ 9367030967041176994 │
#> │ 4.7          ┆ 3.2         ┆ 577056340967428611  ┆ 1155251192985868700 │
#> └──────────────┴─────────────┴─────────────────────┴─────────────────────┘