polars str-join

For dataframe.

Concatenates strings within a column or dataframes

warning This command requires a plugin The polars str-join 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 str-join {flags} (other)

Flags

  • --delimiter, -d {string}: Delimiter to join strings within an expression. Other dataframe when used with a dataframe.
  • --ignore-nulls, -n: Ignore null values. Only available when used as an expression.

Parameters

  • other: Other dataframe with a single series of strings to be concatenated. Required when used with a dataframe, ignored when used as an expression.

Input/output types:

input output
polars_expression polars_expression
polars_selector polars_expression
polars_dataframe polars_dataframe
polars_lazyframe polars_lazyframe

Examples

Join strings in a column

> [[a]; [abc] [abc] [abc]] | polars into-df | polars select (polars col a | polars str-join -d ',') | polars collect
╭───┬─────────────╮
│ # │      a      │
├───┼─────────────┤
│ 0 │ abc,abc,abc │
╰───┴─────────────╯

StrJoin strings across two series

> let other = ([za xs cd] | polars into-df);
    [abc abc abc] | polars into-df | polars str-join $other
╭───┬───────╮
│ # │   0   │
├───┼───────┤
│ 0 │ abcza │
│ 1 │ abcxs │
│ 2 │ abccd │
╰───┴───────╯

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