polars.testing.assert_frame_equal#
- polars.testing.assert_frame_equal(left: DataFrame | LazyFrame, right: DataFrame | LazyFrame, *, check_dtype: bool = True, check_exact: bool = False, rtol: float = 1e-05, atol: float = 1e-08, nans_compare_equal: bool = True, check_column_order: bool = True, check_row_order: bool = True) None [source]#
Raise detailed AssertionError if left does NOT equal right.
- Parameters:
- left
the dataframe to compare.
- right
the dataframe to compare with.
- check_dtype
if True, data types need to match exactly.
- check_exact
if False, test if values are within tolerance of each other (see rtol & atol).
- rtol
relative tolerance for inexact checking. Fraction of values in right.
- atol
absolute tolerance for inexact checking.
- nans_compare_equal
if your assert/test requires float NaN != NaN, set this to False.
- check_column_order
if False, frames will compare equal if the required columns are present, irrespective of the order in which they appear.
- check_row_order
if False, frames will compare equal if the required rows are present, irrespective of the order in which they appear; as this requires sorting, you cannot set on frames that contain unsortable columns.
Examples
>>> from polars.testing import assert_frame_equal >>> df1 = pl.DataFrame({"a": [1, 2, 3]}) >>> df2 = pl.DataFrame({"a": [2, 3, 4]}) >>> assert_frame_equal(df1, df2) AssertionError: Values for column 'a' are different.