polars math abs

For dataframe.

Compute the absolute values of a column expression.

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

Input/output types:

input output
polars_expression polars_expression
polars_selector polars_expression

Examples

Compute the absolute value of an integer column

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

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