polars math bitwise-leading-zeros

For dataframe.

Compute the number of leading unset bits for each element in an integer column expression.

warning This command requires a plugin The polars math bitwise-leading-zeros command resides in the polars plugin. To use this command, you must install and register nu_plugin_polars. See the Plugins chapter in the book for more information.

Command Type

plugin

Signature

> polars math bitwise-leading-zeros {flags}

Input/output types:

input output
polars_expression polars_expression
polars_selector polars_expression

Examples

Count the number of leading unset bits for each element in an integer column

> [[n]; [0] [1] [255]] |
    polars into-df |
    polars select (polars col n | polars math bitwise-leading-zeros) |
    polars collect
╭───┬────╮
│ # │ n  │
├───┼────┤
│ 0 │ 64 │
│ 1 │ 63 │
│ 2 │ 56 │
╰───┴────╯

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.