polars selector digit

For expression.

Select columns whose names consist entirely of digit characters. By default uses Unicode decimal digits; use `--ascii-only` to restrict to ASCII 0-9.

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

Flags

  • --ascii-only, -a: Restrict to ASCII digit characters (0-9) only.

Input/output types:

input output
any polars_selector

Examples

Select columns whose names consist entirely of digits

> {
    "123": [1, 2],
    "abc": [3, 4],
    "4": [5, 6],
} |
polars into-df --as-columns |
polars select (polars selector digit) |
polars sort-by "123" "4" |
polars collect
╭───┬─────┬───╮
│ # │ 123 │ 4 │
├───┼─────┼───┤
│ 0 │   1 │ 5 │
│ 1 │   2 │ 6 │
╰───┴─────┴───╯

Select digit-named columns using ASCII digits only

> {
    "123": [1, 2],
    "abc": [3, 4],
} |
polars into-df --as-columns |
polars select (polars selector digit --ascii-only) |
polars collect
╭───┬─────╮
│ # │ 123 │
├───┼─────┤
│ 0 │   1 │
│ 1 │   2 │
╰───┴─────╯

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