Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

polars selector first for expression

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

Signature

> polars selector first {flags} (n)

Parameters

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

Input/output types:

inputoutput
anypolars_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 │
╰───┴───┴───┴───┴────────────╯