tabulardelta.comparators.pandas_comparator module

class tabulardelta.comparators.pandas_comparator.PandasComparator(join_columns: list[str] | None = None, name: str = '', float_rtol: float = 1e-05, float_atol: float = 0.0, check_row_order: bool = True)[source]

Bases: object

Implements Comparator protocol for comparing pandas DataFrames.

Attributes:
join_columns

Methods

compare(old: pd.DataFrame, new: pd.DataFrame) -> TabularDelta:

Compare two pandas DataFrames

check_row_order: bool = True

Check if row order changed.

Slight performance hit.

compare(old: DataFrame, new: DataFrame) TabularDelta[source]

Compare two pandas DataFrames.

Arguments:
old :pd.DataFrame:

The old table (first table to compare).

new :pd.DataFrame:

The new table (second table to compare).

Returns TabularDelta:

Metadata and results of the comparison.

float_atol: float = 0.0

Absolute tolerance for comparing floats.

float_rtol: float = 1e-05

Relative tolerance for comparing floats.

join_columns: list[str] | None = None

Columns to join on, uses index if unspecified.

name: str = ''

Name of the comparison/tables.

tabulardelta.comparators.pandas_comparator.compare_pandas(old: DataFrame, new: DataFrame, old_dtypes: dict[str, str], new_dtypes: dict[str, str], join_columns: list[str] | None = None, name: str = '', float_rtol: float = 1e-05, float_atol: float = 0, check_row_order: bool = True) TabularDelta[source]

Compare pandas Dataframes.

If data was de-serialized imperfectly, the original dtypes can be specified.

Arguments:
old pd.DataFrame:

The old table (first table to compare).

new pd.DataFrame:

The new table (second table to compare).

old_dtypes dict[str, str]:

The dtypes of the old table (name -> type).

new_dtypes dict[str, str]:

The dtypes of the new table (name -> type).

join_columns list[str] | None:

Columns to join on, uses index if unspecified.

name str:

Name of the comparison/tables.

float_rtol float:

Relative tolerance for comparing floats.

float_atol float:

Absolute tolerance for comparing floats.

check_row_order bool:

Check if row order changed. Slight performance hit.

Returns TabularDelta:

Metadata and results of the comparison.