DataFrameComparison.joined#

DataFrameComparison.joined(
*,
lazy: Literal[True],
) LazyFrame[source]#
DataFrameComparison.joined(
*,
lazy: Literal[False] = False,
) DataFrame

The rows of both data frames that can be joined, regardless of whether column values match in columns which are not used for joining.

Parameters:

lazy – If True, return a lazy frame. Otherwise, return an eager frame (default).

Returns:

A data frame or lazy frame containing the rows that can be joined.

Columns which are not used for joining have a suffix _left for the left data frame and a suffix _right for the right data frame.

Examples

>>> import polars as pl
>>> from diffly import compare_frames
>>> left = pl.DataFrame({"id": [1, 2, 3, 4], "status": ["a", "b", "c", "a"], "value": [10.0, 20.0, 30.0, 40.0]})
>>> right = pl.DataFrame({"id": [1, 2, 3, 5], "status": ["a", "x", "x", "a"], "value": [10.0, 25.0, 30.0, 50.0]})
>>> comparison = compare_frames(left, right, primary_key="id")
>>> comparison.joined()
shape: (3, 5)
┌─────┬─────────────┬──────────────┬────────────┬─────────────┐
│ id  ┆ status_left ┆ status_right ┆ value_left ┆ value_right │
│ --- ┆ ---         ┆ ---          ┆ ---        ┆ ---         │
│ i64 ┆ str         ┆ str          ┆ f64        ┆ f64         │
╞═════╪═════════════╪══════════════╪════════════╪═════════════╡
│ 1   ┆ a           ┆ a            ┆ 10.0       ┆ 10.0        │
│ 2   ┆ b           ┆ x            ┆ 20.0       ┆ 25.0        │
│ 3   ┆ c           ┆ x            ┆ 30.0       ┆ 30.0        │
└─────┴─────────────┴──────────────┴────────────┴─────────────┘