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

transpose for filters

Transposes the table contents so rows become columns and columns become rows.

Signature

> transpose {flags} ...rest

Flags

  • --header-row, -r: use the first input column as the table header-row (or keynames when combined with --as-record)
  • --ignore-titles, -i: don't transpose the column names into values
  • --as-record, -d: transfer to record if the result is a table and contains only one row
  • --keep-last, -l: on repetition of record fields due to header-row, keep the last value obtained
  • --keep-all, -a: on repetition of record fields due to header-row, keep all the values obtained

Parameters

  • ...rest: The names to give columns once transposed.

Input/output types:

inputoutput
tableany
recordtable

Examples

Transposes the table contents with default column names

> [[c1 c2]; [1 2]] | transpose
╭───┬─────────┬─────────╮
│ # │ column0 │ column1 │
├───┼─────────┼─────────┤
│ 0 │ c1      │       1 │
│ 1 │ c2      │       2 │
╰───┴─────────┴─────────╯

Transposes the table contents with specified column names

> [[c1 c2]; [1 2]] | transpose key val
╭───┬─────┬─────╮
│ # │ key │ val │
├───┼─────┼─────┤
│ 0 │ c1  │   1 │
│ 1 │ c2  │   2 │
╰───┴─────┴─────╯

Transposes the table without column names and specify a new column name

> [[c1 c2]; [1 2]] | transpose --ignore-titles val
╭───┬─────╮
│ # │ val │
├───┼─────┤
│ 0 │   1 │
│ 1 │   2 │
╰───┴─────╯

Transfer back to record with -d flag

> {c1: 1, c2: 2} | transpose | transpose --ignore-titles -r -d
╭────┬───╮
│ c1 │ 1 │
│ c2 │ 2 │
╰────┴───╯