polars join for lazyframe

Joins a lazy frame with other lazy frame.

Signature

> polars join {flags} (other) (left_on) (right_on)

Flags

  • --inner, -i: inner joining between lazyframes (default)
  • --left, -l: left join between lazyframes
  • --outer, -o: outer 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 with
  • left_on: Left column(s) to join on
  • right_on: Right column(s) to join on

Input/output types:

inputoutput
anyany

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
╰───┴───┴───┴───┴─────┴─────╯