polars selector by-name

For expression.

Creates a selector that selects columns by name.

warning This command requires a plugin The polars selector by-name command resides in the polars plugin. To use this command, you must install and register nu_plugin_polars. See the Plugins chapter in the book for more information.

Command Type

plugin

Signature

> polars selector by-name {flags} ...rest

Flags

  • --strict: If set, the selector will error if any specified column names do not exist.

Parameters

  • ...rest: Names of columns to select.

Input/output types:

input output
any polars_selector

Examples

Create a selector for columns by name

> polars selector by-name foo bar

Add 10 to specific columns using with-column

> [[a b c]; [1 2 3] [4 5 6]]
                    | polars into-df
                    | polars with-column ((polars selector by-name a c) + 10)
                    | polars collect
╭───┬────┬───┬────╮
│ # │ a  │ b │ c  │
├───┼────┼───┼────┤
│ 0 │ 11 │ 2 │ 13 │
│ 1 │ 14 │ 5 │ 16 │
╰───┴────┴───┴────╯

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.