Spec-Zone.ru › Nushell

polars selector matches for expression

Select all columns that match the given regex pattern.

Signature

> polars selector matches {flags} (pattern)

Parameters

  • pattern: A valid regular expression pattern, compatible with the rust `regex crate https://docs.rs/regex/latest/regex/

Input/output types:

input output
any polars_selector

Examples

Match column names containing an 'a', preceded by a character that is not 'z'

>
                {
                    "foo": ["x", "y"],
                    "bar": [123, 456],
                    "baz": [2.0, 5.5],
                    "zap": [0, 1],
                } |
                polars into-df --as-columns |
                polars select (polars selector matches "[^z]a") |
                polars sort-by bar baz |
                polars collect

╭───┬─────┬──────╮
│ # │ bar │ baz  │
├───┼─────┼──────┤
│ 0 │ 123 │ 2.00 │
│ 1 │ 456 │ 5.50 │
╰───┴─────┴──────╯

Do not match column names ending in 'R' or 'z' (case-insensitively)

>
                {
                    "foo": ["x", "y"],
                    "bar": [123, 456],
                    "baz": [2.0, 5.5],
                    "zap": [0, 1],
                } |
                polars into-df --as-columns |
                polars select (polars selector matches "(?i)R|z$" | polars selector not) |
                polars sort-by foo zap |
                polars collect

╭───┬─────┬─────╮
│ # │ foo │ zap │
├───┼─────┼─────┤
│ 0 │ x   │   0 │
│ 1 │ y   │   1 │
╰───┴─────┴─────╯

Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/polars_selector_matches.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API