W3cubDocs

/Nushell

dfr rename for dataframe or lazyframe

Rename a dataframe column.

Signature

> dfr rename {flags} (columns) (new names)

Parameters

  • columns: Column(s) to be renamed. A string or list of strings
  • new names: New names for the selected column(s). A string or list of strings

Input/output types:

input output
any any

Examples

Renames a series

> [5678] |dfr into-df|dfr rename'0'new_name
╭───┬──────────╮
# │ new_name │
├───┼──────────┤
05
16
27
38
╰───┴──────────╯

Renames a dataframe column

> [[ab]; [12] [34]] |dfr into-df|dfr renameaa_new
╭───┬───────┬───╮
# │ a_new │ b │
├───┼───────┼───┤
012
134
╰───┴───────┴───╯

Renames two dataframe columns

> [[ab]; [12] [34]] |dfr into-df|dfr rename [ab] [a_newb_new]
╭───┬───────┬───────╮
# │ a_new │ b_new │
├───┼───────┼───────┤
012
134
╰───┴───────┴───────╯

Tips: Dataframe commands were not shipped in the official binaries by default, you have to build it with --features=dataframe flag

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