polars math sign

For dataframe.

Compute the element-wise sign of a column expression, returning -1, 0, or 1.

warning This command requires a plugin The polars math sign 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 sign {flags}

Input/output types:

input output
polars_expression polars_expression
polars_selector polars_expression

Examples

Compute the element-wise sign of an integer column

> [[a]; [0] [-1] [2] [-3] [4]] | polars into-df | polars select (polars col a | polars math sign) | polars collect
╭───┬────╮
│ # │ a  │
├───┼────┤
│ 0 │  0 │
│ 1 │ -1 │
│ 2 │  1 │
│ 3 │ -1 │
│ 4 │  1 │
╰───┴────╯

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