pandas.testing.assert_index_equal

pandas.testing.assert_index_equal(left, right, exact='equiv', check_names=True, check_less_precise=NoDefault.no_default, check_exact=True, check_categorical=True, check_order=True, rtol=1e-05, atol=1e-08, obj='Index')[source]

Check that left and right Index are equal.

Parameters
leftIndex
rightIndex
exactbool or {‘equiv’}, default ‘equiv’

Whether to check the Index class, dtype and inferred_type are identical. If ‘equiv’, then RangeIndex can be substituted for Int64Index as well.

check_namesbool, default True

Whether to check the names attribute.

check_less_precisebool or int, default False

Specify comparison precision. Only used when check_exact is False. 5 digits (False) or 3 digits (True) after decimal points are compared. If int, then specify the digits to compare.

Deprecated since version 1.1.0: Use rtol and atol instead to define relative/absolute tolerance, respectively. Similar to math.isclose().

check_exactbool, default True

Whether to compare number exactly.

check_categoricalbool, default True

Whether to compare internal Categorical exactly.

check_orderbool, default True

Whether to compare the order of index entries as well as their values. If True, both indexes must contain the same elements, in the same order. If False, both indexes must contain the same elements, but in any order.

New in version 1.2.0.

rtolfloat, default 1e-5

Relative tolerance. Only used when check_exact is False.

New in version 1.1.0.

atolfloat, default 1e-8

Absolute tolerance. Only used when check_exact is False.

New in version 1.1.0.

objstr, default ‘Index’

Specify object name being compared, internally used to show appropriate assertion message.

Examples

>>> from pandas.testing import assert_index_equal
>>> a = pd.Index([1, 2, 3])
>>> b = pd.Index([1, 2, 3])
>>> assert_index_equal(a, b)