🍾 Xarray is now 10 years old! 🎉

xarray.DataArray.identical

xarray.DataArray.identical#

DataArray.identical(other)[source]#

Like equals, but also checks the array name and attributes, and attributes on all coordinates.

Parameters:

other (DataArray) – DataArray to compare to.

Returns:

equal (bool) – True if the two DataArrays are identical.

Examples

>>> a = xr.DataArray([1, 2, 3], dims="X", attrs=dict(units="m"), name="Width")
>>> b = xr.DataArray([1, 2, 3], dims="X", attrs=dict(units="m"), name="Width")
>>> c = xr.DataArray([1, 2, 3], dims="X", attrs=dict(units="ft"), name="Width")
>>> a
<xarray.DataArray 'Width' (X: 3)> Size: 24B
array([1, 2, 3])
Dimensions without coordinates: X
Attributes:
    units:    m
>>> b
<xarray.DataArray 'Width' (X: 3)> Size: 24B
array([1, 2, 3])
Dimensions without coordinates: X
Attributes:
    units:    m
>>> c
<xarray.DataArray 'Width' (X: 3)> Size: 24B
array([1, 2, 3])
Dimensions without coordinates: X
Attributes:
    units:    ft
>>> a.equals(b)
True
>>> a.identical(b)
True
>>> a.equals(c)
True
>>> a.identical(c)
False