polars math bitwise-count-zeros for dataframe
Compute the number of unset bits for each element in an integer column expression.
Signature
> polars math bitwise-count-zeros {flags}
Input/output types:
| input | output |
|---|---|
| polars_expression | polars_expression |
| polars_selector | polars_expression |
Examples
Count the number of unset bits for each element in an integer column
> [[n]; [0] [1] [7] [255]] |
polars into-df |
polars select (polars col n | polars math bitwise-count-zeros) |
polars collect
╭───┬────╮
│ # │ n │
├───┼────┤
│ 0 │ 64 │
│ 1 │ 63 │
│ 2 │ 61 │
│ 3 │ 56 │
╰───┴────╯