Spec-Zone.ru › Nushell

polars selector alphanumeric for expression

Select all columns with alphanumeric names (eg: only letters). Matching column names cannot contain *any* non-alphanumeric characters. Note that the definition of "alphanumeric" consists of all valid Unicode alphanumeric characters by default; this can be changed by setting `ascii_only=true`.

Signature

> polars selector alphanumeric {flags}

Flags

  • --ascii-only, -a: Indicate whether to consider only ASCII alphanumeric characters, or the full Unicode range of valid letters (accented, idiographic, etc).
  • --ignore-spaces, -s: Indicate whether to ignore the presence of spaces in column names; if so, only the other (non-space) characters are considered.

Input/output types:

input output
any polars_selector

Examples

Select columns with alphanumeric names.

>
                {
                    "1st_col": [100, 200, 300],
                    "flagged": [true, false, true],
                    "00prefix": ["01:aa", "02:bb", "03:cc"],
                    "last col": ["x", "y", "z"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alphanumeric) |
                polars sort-by 00prefix flagged |
                polars collect

╭───┬─────────┬──────────╮
│ # │ flagged │ 00prefix │
├───┼─────────┼──────────┤
│ 0 │ true    │ 01:aa    │
│ 1 │ false   │ 02:bb    │
│ 2 │ true    │ 03:cc    │
╰───┴─────────┴──────────╯

Select columns with alphanumeric names ignoring spaces.

>
                {
                    "1st_col": [100, 200, 300],
                    "flagged": [true, false, true],
                    "00prefix": ["01:aa", "02:bb", "03:cc"],
                    "last col": ["x", "y", "z"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alphanumeric --ignore-spaces) |
                polars sort-by 00prefix 'last col' flagged |
                polars collect

╭───┬─────────┬──────────┬──────────╮
│ # │ flagged │ 00prefix │ last col │
├───┼─────────┼──────────┼──────────┤
│ 0 │ true    │ 01:aa    │ x        │
│ 1 │ false   │ 02:bb    │ y        │
│ 2 │ true    │ 03:cc    │ z        │
╰───┴─────────┴──────────┴──────────╯

Select all columns except for those with alphanumeric names.

>
                {
                    "1st_col": [100, 200, 300],
                    "flagged": [true, false, true],
                    "00prefix": ["01:aa", "02:bb", "03:cc"],
                    "last col": ["x", "y", "z"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alphanumeric | polars selector not) |
                polars sort-by '1st_col' 'last col' |
                polars collect

╭───┬─────────┬──────────╮
│ # │ 1st_col │ last col │
├───┼─────────┼──────────┤
│ 0 │     100 │ x        │
│ 1 │     200 │ y        │
│ 2 │     300 │ z        │
╰───┴─────────┴──────────╯

Select all columns except for those with alphanumeric names, ignoring spaces.

>
                {
                    "1st_col": [100, 200, 300],
                    "flagged": [true, false, true],
                    "00prefix": ["01:aa", "02:bb", "03:cc"],
                    "last col": ["x", "y", "z"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alphanumeric --ignore-spaces | polars selector not) |
                polars collect

╭───┬─────────╮
│ # │ 1st_col │
├───┼─────────┤
│ 0 │     100 │
│ 1 │     200 │
│ 2 │     300 │
╰───┴─────────╯

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

Spec-Zone.ru

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