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

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

Signature

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

Parameters

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

Input/output types:

inputoutput
anypolars_selector

Examples

Match columns ending with a 'z'

> {
        "foo": ["x", "y"],
        "bar": [123, 456],
        "baz": [2.0, 5.5],
        "zap": [false, true],
    } |
    polars into-df --as-columns |
    polars select (polars selector ends-with z) |
    polars sort-by baz |
    polars collect
╭───┬──────╮
│ # │ baz  │
├───┼──────┤
│ 0 │ 2.00 │
│ 1 │ 5.50 │
╰───┴──────╯

Match columns ending with either the letter 'z' or 'r'

> {
        "foo": ["x", "y"],
        "bar": [123, 456],
        "baz": [2.0, 5.5],
        "zap": [false, true],
    } |
    polars into-df --as-columns |
    polars select (polars selector ends-with z r) |
    polars sort-by bar baz |
    polars collect
╭───┬─────┬──────╮
│ # │ bar │ baz  │
├───┼─────┼──────┤
│ 0 │ 123 │ 2.00 │
│ 1 │ 456 │ 5.50 │
╰───┴─────┴──────╯

Match columns ending with except the letter 'z'

> {
        "foo": ["x", "y"],
        "bar": [123, 456],
        "baz": [2.0, 5.5],
        "zap": [false, true],
    } |
    polars into-df --as-columns |
    polars select (polars selector ends-with z | polars selector not) |
    polars sort-by foo bar zap |
    polars collect
╭───┬─────┬─────┬───────╮
│ # │ foo │ bar │  zap  │
├───┼─────┼─────┼───────┤
│ 0 │ x   │ 123 │ false │
│ 1 │ y   │ 456 │ true  │
╰───┴─────┴─────┴───────╯