pub fn assert_dataframe_equal(
left: &DataFrame,
right: &DataFrame,
options: DataFrameEqualOptions,
) -> PolarsResult<()>Expand description
Verifies that two DataFrames are equal according to a set of configurable criteria.
This function serves as the main entry point for comparing DataFrames, first validating schema compatibility and then comparing the actual data values column by column.
§Arguments
left- The first DataFrame to compareright- The second DataFrame to compareoptions- ADataFrameEqualOptionsstruct containing configuration parameters:check_row_order- If true, rows must be in the same ordercheck_column_order- If true, columns must be in the same ordercheck_dtypes- If true, verifies data types match for corresponding columnscheck_exact- If true, requires exact equality for float valuesrtol- Relative tolerance for float comparisonatol- Absolute tolerance for float comparisoncategorical_as_str- If true, converts categorical values to strings before comparison
§Returns
Ok(())if DataFrames match according to all specified criteriaErrwith details about the first mismatch encountered:- Schema mismatches (column names, order, or data types)
- Height (row count) mismatch
- Value mismatches in specific columns
§Order of Checks
- Schema validation (column names, order, and data types via
assert_dataframe_schema_equal) - DataFrame height (row count)
- Row ordering (sorts both DataFrames if
check_row_orderis false) - Column-by-column value comparison (delegated to
assert_series_values_equal)
§Behavior
When check_row_order is false, both DataFrames are sorted using all columns to ensure
consistent ordering before value comparison. This allows for row-order-independent equality
checking while maintaining deterministic results.