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

rotate for filters

Rotates a table or record clockwise (default) or counter-clockwise (use --ccw flag).

Signature

> rotate {flags} ...rest

Flags

  • --ccw: rotate counter clockwise

Parameters

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

Input/output types:

inputoutput
list<any>table
recordtable
stringtable
tabletable

Examples

Rotate a record clockwise, producing a table (like transpose but with column order reversed)

> {a:1, b:2} | rotate
╭───┬─────────┬─────────╮
│ # │ column0 │ column1 │
├───┼─────────┼─────────┤
│ 0 │       1 │ a       │
│ 1 │       2 │ b       │
╰───┴─────────┴─────────╯

Rotate 2x3 table clockwise

> [[a b]; [1 2] [3 4] [5 6]] | rotate
╭───┬─────────┬─────────┬─────────┬─────────╮
│ # │ column0 │ column1 │ column2 │ column3 │
├───┼─────────┼─────────┼─────────┼─────────┤
│ 0 │       5 │       3 │       1 │ a       │
│ 1 │       6 │       4 │       2 │ b       │
╰───┴─────────┴─────────┴─────────┴─────────╯

Rotate table clockwise and change columns names

> [[a b]; [1 2]] | rotate col_a col_b
╭───┬───────┬───────╮
│ # │ col_a │ col_b │
├───┼───────┼───────┤
│ 0 │     1 │ a     │
│ 1 │     2 │ b     │
╰───┴───────┴───────╯

Rotate table counter clockwise

> [[a b]; [1 2]] | rotate --ccw
╭───┬─────────┬─────────╮
│ # │ column0 │ column1 │
├───┼─────────┼─────────┤
│ 0 │ b       │       2 │
│ 1 │ a       │       1 │
╰───┴─────────┴─────────╯

Rotate table counter-clockwise

> [[a b]; [1 2] [3 4] [5 6]] | rotate --ccw
╭───┬─────────┬─────────┬─────────┬─────────╮
│ # │ column0 │ column1 │ column2 │ column3 │
├───┼─────────┼─────────┼─────────┼─────────┤
│ 0 │ b       │       2 │       4 │       6 │
│ 1 │ a       │       1 │       3 │       5 │
╰───┴─────────┴─────────┴─────────┴─────────╯

Rotate table counter-clockwise and change columns names

> [[a b]; [1 2]] | rotate --ccw col_a col_b
╭───┬───────┬───────╮
│ # │ col_a │ col_b │
├───┼───────┼───────┤
│ 0 │ b     │     2 │
│ 1 │ a     │     1 │
╰───┴───────┴───────╯