polars join
for lazyframe
Joins a lazy frame with other lazy frame.
This command requires a plugin
The polars 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.
Signature
> polars join {flags} (other) (left_on) (right_on)
Flags
--inner, -i
: inner joining between lazyframes (default)--left, -l
: left join between lazyframes--full, -f
: full join between lazyframes--cross, -c
: cross join between lazyframes--suffix, -s {string}
: Suffix to use on columns with same name
Parameters
other
: LazyFrame to join withleft_on
: Left column(s) to join onright_on
: Right column(s) to join on
Input/output types:
input | output |
---|---|
any | any |
Examples
Join two lazy dataframes
> let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | polars into-lazy);
let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | polars into-lazy);
$df_a | polars join $df_b a foo | polars collect
╭───┬───┬───┬───┬─────┬─────╮
│ # │ a │ b │ c │ bar │ ham │
├───┼───┼───┼───┼─────┼─────┤
│ 0 │ 1 │ a │ 0 │ a │ let │
│ 1 │ 2 │ b │ 1 │ c │ var │
│ 2 │ 1 │ c │ 2 │ a │ let │
│ 3 │ 1 │ c │ 3 │ a │ let │
╰───┴───┴───┴───┴─────┴─────╯
Join one eager dataframe with a lazy dataframe
> let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | polars into-df);
let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | polars into-lazy);
$df_a | polars join $df_b a foo
╭───┬───┬───┬───┬─────┬─────╮
│ # │ a │ b │ c │ bar │ ham │
├───┼───┼───┼───┼─────┼─────┤
│ 0 │ 1 │ a │ 0 │ a │ let │
│ 1 │ 2 │ b │ 1 │ c │ var │
│ 2 │ 1 │ c │ 2 │ a │ let │
│ 3 │ 1 │ c │ 3 │ a │ let │
╰───┴───┴───┴───┴─────┴─────╯