Evaluate the number of set bits.
Description
Evaluate the number of set bits.
Usage
<Expr>$bitwise_count_ones()
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(n = c(-1L, 0L, 2L, 1L))
df$with_columns(set_bits = pl$col("n")$bitwise_count_ones())
#> shape: (4, 2)
#> ┌─────┬──────────┐
#> │ n ┆ set_bits │
#> │ --- ┆ --- │
#> │ i32 ┆ u32 │
#> ╞═════╪══════════╡
#> │ -1 ┆ 32 │
#> │ 0 ┆ 0 │
#> │ 2 ┆ 1 │
#> │ 1 ┆ 1 │
#> └─────┴──────────┘