pandas.testing.assert_index_equal

pandas 3.1.1 · Testing, errors, and warnings · function

Compare two indexes and raise AssertionError when the configured equality checks fail.

Call syntax

pd.testing.assert_index_equal(…) Full signature
pd.testing.assert_index_equal(
    left,
    right,
    exact=…,
    check_names=True,
    check_exact=True,
    check_categorical=True,
    check_order=True,
    rtol=1e-05,
    atol=1e-08,
    obj=None,
    *,
    check_freq=…,
)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
left Required
Positional or keyword
Index

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

right Required
Positional or keyword
Index

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

exact Optional
Positional or keyword
bool or {'equiv'}

Choose whether the parser requires an exact format match.

check_names Optional
Positional or keyword
Default True
bool

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

check_exact Optional
Positional or keyword
Default True
bool

Choose whether numeric equality tests require exact values.

check_categorical Optional
Positional or keyword
Default True
bool

Choose whether a test compares categorical internals.

check_order Optional
Positional or keyword
Default True
bool
rtol Optional
Positional or keyword
Default 1e-05
float

Set the acceptable relative difference in a numeric equality check.

atol Optional
Positional or keyword
Default 1e-08
float

Set the acceptable absolute difference in a numeric equality check.

obj Optional
Positional or keyword
Default None
str

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

check_freq Optional
Keyword only
bool

Choose whether a test compares frequency metadata.

Returns

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