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