pandas.testing.assert_frame_equal

pandas 3.1.1 · Testing, errors, and warnings · function

Compare expected and actual DataFrames in a test, with options for labels, dtypes and numeric tolerances.

Call syntax

pd.testing.assert_frame_equal(…) Full signature
pd.testing.assert_frame_equal(
    left,
    right,
    check_dtype=True,
    check_index_type='equiv',
    check_column_type='equiv',
    check_frame_type=True,
    check_names=True,
    by_blocks=False,
    check_exact=…,
    check_datetimelike_compat=False,
    check_categorical=True,
    check_like=False,
    check_freq=…,
    check_flags=True,
    rtol=…,
    atol=…,
    obj='DataFrame',
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
left Required
Positional or keyword
DataFrame

Supply the left-hand input or the left endpoint of the interval.

right Required
Positional or keyword
DataFrame

Supply the right-hand input or the right endpoint of the interval.

check_dtype Optional
Positional or keyword
Default True
bool

Choose whether a test requires the two dtypes to match.

check_index_type Optional
Positional or keyword
Default 'equiv'
bool or {'equiv'}
check_column_type Optional
Positional or keyword
Default 'equiv'
bool or {'equiv'}
check_frame_type Optional
Positional or keyword
Default True
bool
check_names Optional
Positional or keyword
Default True
bool

Choose whether a test compares index, column, or Series names.

by_blocks Optional
Positional or keyword
Default False
bool
check_exact Optional
Positional or keyword
bool

Choose whether numeric equality tests require exact values.

check_datetimelike_compat Optional
Positional or keyword
Default False
bool
check_categorical Optional
Positional or keyword
Default True
bool

Choose whether a test compares categorical internals.

check_like Optional
Positional or keyword
Default False
bool
check_freq Optional
Positional or keyword
bool

Choose whether a test compares frequency metadata.

check_flags Optional
Positional or keyword
Default True
bool
rtol Optional
Positional or keyword
float

Set the acceptable relative difference in a numeric equality check.

atol Optional
Positional or keyword
float

Set the acceptable absolute difference in a numeric equality check.

obj Optional
Positional or keyword
Default 'DataFrame'
str

Provide the pandas object, scalar, or array-like input described in the accepted values.

Returns

None when the checks pass. Raises AssertionError when they fail.