Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

math abs for math

Returns the absolute value of a number.

Signature

> math abs {flags} ...rest

Parameters

  • ...rest: The cell-paths/columns to operate on.

Input/output types:

inputoutput
numbernumber
durationduration
filesizefilesize
list<number>list<number>
list<duration>list<duration>
list<filesize>list<filesize>
rangelist<number>
recordrecord

Examples

Compute absolute value of each number in a list of numbers.

> [-50 -100.0 25] | math abs
╭───┬────────╮
│ 0 │     50 │
│ 1 │ 100.00 │
│ 2 │     25 │
╰───┴────────╯

Compute the absolute value of list-valued columns in a record.

> {alice: [-1 -2 -3], bob: [-4 -5]} | math abs
╭───────┬───────────╮
│       │ ╭───┬───╮ │
│ alice │ │ 0 │ 1 │ │
│       │ │ 1 │ 2 │ │
│       │ │ 2 │ 3 │ │
│       │ ╰───┴───╯ │
│       │ ╭───┬───╮ │
│ bob   │ │ 0 │ 4 │ │
│       │ │ 1 │ 5 │ │
│       │ ╰───┴───╯ │
╰───────┴───────────╯

Compute the absolute value of a single column using a cell path.

> {alice: [-1 -2 -3], bob: [-4 -5]} | math abs alice
╭───────┬────────────╮
│       │ ╭───┬───╮  │
│ alice │ │ 0 │ 1 │  │
│       │ │ 1 │ 2 │  │
│       │ │ 2 │ 3 │  │
│       │ ╰───┴───╯  │
│       │ ╭───┬────╮ │
│ bob   │ │ 0 │ -4 │ │
│       │ │ 1 │ -5 │ │
│       │ ╰───┴────╯ │
╰───────┴────────────╯