polars selector first

For expression.

Creates a selector that selects the first column(s) by index.

warning This command requires a plugin The polars selector first 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 first {flags} (n)

Parameters

  • n: Number of columns to select from the beginning (default: 1).

Input/output types:

input output
any polars_selector

Examples

Create a selector for the first column

> polars selector first

Create a selector for the first 3 columns

> polars selector first 3

Create a new column from the first column using with-column

> [[a b c]; [1 2 3] [4 5 6]]
                    | polars into-df
                    | polars with-column ((polars selector first) * 10 | polars as a_times_10)
                    | polars collect
╭───┬───┬───┬───┬────────────╮
│ # │ a │ b │ c │ a_times_10 │
├───┼───┼───┼───┼────────────┤
│ 0 │ 1 │ 2 │ 3 │         10 │
│ 1 │ 4 │ 5 │ 6 │         40 │
╰───┴───┴───┴───┴────────────╯

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