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

rename for filters

Creates a new table with columns renamed.

Signature

> rename {flags} ...rest

Flags

  • --column, -c {record}: column name to be changed
  • --block, -b {closure(any)}: A closure to apply changes on each column

Parameters

  • ...rest: The new names for the columns.

Input/output types:

inputoutput
recordrecord
tabletable

Examples

Rename a column

> [[a, b]; [1, 2]] | rename my_column
╭───┬───────────┬───╮
│ # │ my_column │ b │
├───┼───────────┼───┤
│ 0 │         1 │ 2 │
╰───┴───────────┴───╯

Rename many columns

> [[a, b, c]; [1, 2, 3]] | rename eggs ham bacon
╭───┬──────┬─────┬───────╮
│ # │ eggs │ ham │ bacon │
├───┼──────┼─────┼───────┤
│ 0 │    1 │   2 │     3 │
╰───┴──────┴─────┴───────╯

Rename a specific column

> [[a, b, c]; [1, 2, 3]] | rename --column { a: ham }
╭───┬─────┬───┬───╮
│ # │ ham │ b │ c │
├───┼─────┼───┼───┤
│ 0 │   1 │ 2 │ 3 │
╰───┴─────┴───┴───╯

Rename the fields of a record

> {a: 1 b: 2} | rename x y
╭───┬───╮
│ x │ 1 │
│ y │ 2 │
╰───┴───╯

Rename fields based on a given closure

> {abc: 1, bbc: 2} | rename --block {str replace --all 'b' 'z'}
╭─────┬───╮
│ azc │ 1 │
│ zzc │ 2 │
╰─────┴───╯