Skip to main content
`Ctrl`+`K`

# pandas.testing.assert_extension_array_equal

pandas.testing.assert_extension_array_equal(left, right, check_dtype=True, index_values=None, check_exact=<no_default>, rtol=<no_default>, atol=<no_default>, obj='ExtensionArray')

  Check that left and right ExtensionArrays are equal.

  This method compares two `ExtensionArray` instances for equality, including checks for missing values, the dtype of the arrays, and the exactness of the comparison (or tolerance when comparing floats).

  Parameters:
    left, right ExtensionArray

      The two arrays to compare.

    check_dtype bool, default True

      Whether to check if the ExtensionArray dtypes are identical.

    index_values Index | numpy.ndarray, default None

      Optional index (shared by both left and right), used in output.

    check_exact bool, default False

      Whether to compare number exactly.

      Changed in version 2.2.0: Defaults to True for integer dtypes if none of `check_exact`, `rtol` and `atol` are specified.

    rtol float, default 1e-5

      Relative tolerance. Only used when check_exact is False.

    atol float, default 1e-8

      Absolute tolerance. Only used when check_exact is False.

    obj str, default ‘ExtensionArray’

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

      Added in version 2.0.0.

  See also

  `testing.assert_series_equal`

    Check that left and right `Series` are equal.

  `testing.assert_frame_equal`

    Check that left and right `DataFrame` are equal.

  `testing.assert_index_equal`

    Check that left and right `Index` are equal.

  Notes

  Missing values are checked separately from valid values. A mask of missing values is computed for each and checked to match. The remaining all-valid values are cast to object dtype and checked.

  Examples

      >>> from pandas import testing as tm
      >>> a = pd.Series([1, 2, 3, 4])
      >>> b, c = a.array, a.array
      >>> tm.assert_extension_array_equal(b, c)