xarray.DataArray.equals#
- DataArray.equals(other)[source]#
True if two DataArrays have the same dimensions, coordinates and values; otherwise False.
DataArrays can still be equal (like pandas objects) if they have NaN values in the same locations.
This method is necessary because v1 == v2 for
DataArray
does element-wise comparisons (like numpy.ndarrays).- Parameters
other (
DataArray
) – DataArray to compare to.- Returns
equal (
bool
) – True if the two DataArrays are equal.
Examples
>>> a = xr.DataArray([1, 2, 3], dims="X") >>> b = xr.DataArray([1, 2, 3], dims="X", attrs=dict(units="m")) >>> c = xr.DataArray([1, 2, 3], dims="Y") >>> d = xr.DataArray([3, 2, 1], dims="X") >>> a <xarray.DataArray (X: 3)> Size: 24B array([1, 2, 3]) Dimensions without coordinates: X >>> b <xarray.DataArray (X: 3)> Size: 24B array([1, 2, 3]) Dimensions without coordinates: X Attributes: units: m >>> c <xarray.DataArray (Y: 3)> Size: 24B array([1, 2, 3]) Dimensions without coordinates: Y >>> d <xarray.DataArray (X: 3)> Size: 24B array([3, 2, 1]) Dimensions without coordinates: X
>>> a.equals(b) True >>> a.equals(c) False >>> a.equals(d) False