DataFrameComparison.fraction_same#
- DataFrameComparison.fraction_same(column: Literal[None] = None, /) dict[str, float][source]#
- DataFrameComparison.fraction_same(column: str, /) float
Compute the fraction of matching values.
- Parameters:
column – The column to compute the fraction of matching values for. If
None(default), compute the fraction for all columns.- Returns:
A single float for the fraction or a mapping from column name to fraction, depending on the value of
column. The mapping contains all common columns. It is empty in case there are no common (non-primary key) columns.
Examples
>>> import polars as pl >>> from diffly import compare_frames >>> left = pl.DataFrame({"id": [1, 2, 3], "status": ["a", "b", "c"], "value": [10.0, 20.0, 30.0]}) >>> right = pl.DataFrame({"id": [1, 2, 3], "status": ["a", "x", "x"], "value": [10.0, 25.0, 30.0]}) >>> comparison = compare_frames(left, right, primary_key="id") >>> comparison.fraction_same("value") 0.6666666666666666 >>> comparison.fraction_same() {'status': 0.3333333333333333, 'value': 0.6666666666666666}