Spec-Zone.ru › Nushell

polars str-replace for dataframe

Replace the leftmost (sub)string by a regex pattern.

Signature

> polars str-replace {flags}

Flags

  • --pattern, -p {string}: Regex pattern to be matched.
  • --replace, -r {string}: Replacing string.

Input/output types:

input output
polars_dataframe polars_dataframe
polars_lazyframe polars_lazyframe
polars_expression polars_expression

Examples

Replaces string in column

> [[a]; [abc] [abcabc]] | polars into-df | polars select (polars col a | polars str-replace --pattern ab --replace AB) | polars collect
╭───┬────────╮
│ # │   a    │
├───┼────────┤
│ 0 │ ABc    │
│ 1 │ ABcabc │
╰───┴────────╯

Replaces string

> [abc abc abc] | polars into-df | polars str-replace --pattern ab --replace AB
╭───┬─────╮
│ # │  0  │
├───┼─────┤
│ 0 │ ABc │
│ 1 │ ABc │
│ 2 │ ABc │
╰───┴─────╯

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

Spec-Zone.ru

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