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 starts-with for expression

Select columns that start with the given substring(s).

Signature

> polars selector starts-with {flags} ...rest

Parameters

  • ...rest: Select columns that start with the given substring(s).

Input/output types:

inputoutput
anypolars_selector

Examples

Match columns starting with a 'b'

> {
        "foo": [1.0, 2.0],
        "bar": [3.0, 4.0],
        "baz": [5, 6],
        "zap": [7, 8],
    } |
    polars into-df --as-columns |
    polars select (polars selector starts-with b) |
    polars sort-by bar baz |
    polars collect
╭───┬──────┬─────╮
│ # │ bar  │ baz │
├───┼──────┼─────┤
│ 0 │ 3.00 │   5 │
│ 1 │ 4.00 │   6 │
╰───┴──────┴─────╯

Match columns starting with either the letter 'b' or 'z'

> {
        "foo": [1.0, 2.0],
        "bar": [3.0, 4.0],
        "baz": [5, 6],
        "zap": [7, 8],
    } |
    polars into-df --as-columns |
    polars select (polars selector starts-with b z) |
    polars sort-by bar baz zap |
    polars collect
╭───┬──────┬─────┬─────╮
│ # │ bar  │ baz │ zap │
├───┼──────┼─────┼─────┤
│ 0 │ 3.00 │   5 │   7 │
│ 1 │ 4.00 │   6 │   8 │
╰───┴──────┴─────┴─────╯