polars selector starts-with

For expression.

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

warning This command requires a plugin The polars selector starts-with 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 starts-with {flags} ...rest

Parameters

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

Input/output types:

input output
any polars_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 │
╰───┴──────┴─────┴─────╯

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