Spec-Zone.ru › Nushell

polars selector alpha for expression

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

Signature

> polars selector alpha {flags}

Flags

  • --ascii-only, -a: Indicate whether to consider only ASCII alphabetic 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 alphabetic names; note that accented characters and kanji are recognised as alphabetic here.

>
                {
                    "no1": [100, 200, 300],
                    "café": ["espresso", "latte", "mocha"],
                    "t or f": [true, false, null],
                    "hmm": ["aaa", "bbb", "ccc"],
                    "都市": ["東京", "大阪", "京都"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alpha) |
                polars sort-by  café hmm 都市 |
                polars collect

╭───┬──────────┬─────┬──────╮
│ # │   café   │ hmm │ 都市 │
├───┼──────────┼─────┼──────┤
│ 0 │ espresso │ aaa │ 東京 │
│ 1 │ latte    │ bbb │ 大阪 │
│ 2 │ mocha    │ ccc │ 京都 │
╰───┴──────────┴─────┴──────╯

Constrain the definition of "alphabetic" to ASCII characters only.

>
                {
                    "no1": [100, 200, 300],
                    "café": ["espresso", "latte", "mocha"],
                    "t or f": [true, false, null],
                    "hmm": ["aaa", "bbb", "ccc"],
                    "都市": ["東京", "大阪", "京都"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alpha --ascii-only) |
                polars collect

╭───┬─────╮
│ # │ hmm │
├───┼─────┤
│ 0 │ aaa │
│ 1 │ bbb │
│ 2 │ ccc │
╰───┴─────╯

Constrain the definition of "alphabetic" to ASCII characters only and ignore whitespace.

>
                {
                    "no1": [100, 200, 300],
                    "café": ["espresso", "latte", "mocha"],
                    "t or f": [true, false, null],
                    "hmm": ["aaa", "bbb", "ccc"],
                    "都市": ["東京", "大阪", "京都"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alpha --ascii-only --ignore-spaces) |
                polars sort-by  "t or f" hmm |
                polars collect

╭───┬────────┬─────╮
│ # │ t or f │ hmm │
├───┼────────┼─────┤
│ 0 │        │ ccc │
│ 1 │ false  │ bbb │
│ 2 │ true   │ aaa │
╰───┴────────┴─────╯

Select all columns except for those with alphabetic names.

>
                {
                    "no1": [100, 200, 300],
                    "café": ["espresso", "latte", "mocha"],
                    "t or f": [true, false, null],
                    "hmm": ["aaa", "bbb", "ccc"],
                    "都市": ["東京", "大阪", "京都"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alpha | polars selector not) |
                polars sort-by no1 "t or f"|
                polars collect

╭───┬─────┬────────╮
│ # │ no1 │ t or f │
├───┼─────┼────────┤
│ 0 │ 100 │ true   │
│ 1 │ 200 │ false  │
│ 2 │ 300 │        │
╰───┴─────┴────────╯

Select all columns except for those with alphabetic names and do not have spaces.

>
                {
                    "no1": [100, 200, 300],
                    "café": ["espresso", "latte", "mocha"],
                    "t or f": [true, false, null],
                    "hmm": ["aaa", "bbb", "ccc"],
                    "都市": ["東京", "大阪", "京都"],
                } |
                polars into-df --as-columns |
                polars select (polars selector alpha --ignore-spaces | polars selector not) |
                polars sort-by no1 |
                polars collect

╭───┬─────╮
│ # │ no1 │
├───┼─────┤
│ 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_alpha.html

Spec-Zone.ru

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