rename
for filters> rename {flags} ...rest
--column, -c {list<string>}
: column name to be changed--block, -b {closure(any)}
: A closure to apply changes on each column...rest
: the new names for the columnsinput | output |
---|---|
record | record |
table | table |
Rename a column
> [[a, b]; [1, 2]] |renamemy_column
╭───┬───────────┬───╮
│# │ my_column │ b │
├───┼───────────┼───┤
│0│1│2│
╰───┴───────────┴───╯
Rename many columns
> [[a, b, c]; [1, 2, 3]] |renameeggshambacon
╭───┬──────┬─────┬───────╮
│# │ eggs │ ham │ bacon │
├───┼──────┼─────┼───────┤
│0│1│2│3│
╰───┴──────┴─────┴───────╯
Rename a specific column
> [[a, b, c]; [1, 2, 3]] |rename-c [aham]
╭───┬─────┬───┬───╮
│# │ ham │ b │ c │
├───┼─────┼───┼───┤
│0│1│2│3│
╰───┴─────┴───┴───╯
Rename the fields of a record
> {a:1b:2} |renamexy
╭───┬───╮
│x│1│
│y│2│
╰───┴───╯
Rename fields based on a given closure
> {abc:1, bbc:2} |rename-b {str replace-a'b''z'}
╭─────┬───╮
│azc│1│
│zzc│2│
╰─────┴───╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/rename.html