W3cubDocs

/Nushell

rename for filters

Creates a new table with columns renamed.

Signature

> rename {flags} ...rest

Flags

  • --column, -c {list<string>}: 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:

input output
record record
table table

Examples

Rename a column

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

Rename many columns

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

Rename a specific column

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

Rename the fields of a record

> {a:1b:2} |renamexy
╭───┬───╮
x1
y2
╰───┴───╯

Rename fields based on a given closure

> {abc:1, bbc:2} |rename-b {str replace-a'b''z'}
╭─────┬───╮
azc1
zzc2
╰─────┴───╯

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/rename.html