# xarray.DataArray.equals

#### DataArray.equals(other)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataarray.py#L4882-L4944)

Check whether two DataArrays are equal.

Two DataArrays are equal if they have the same dimensions, coordinates
and values.

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`](xarray.DataArray.html.md#xarray.DataArray)) – DataArray to compare to.
* **Returns:**
  **equal** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – True if the two DataArrays are equal.

#### SEE ALSO
[`DataArray.broadcast_equals`](xarray.DataArray.broadcast_equals.html.md#xarray.DataArray.broadcast_equals), [`DataArray.identical`](xarray.DataArray.identical.html.md#xarray.DataArray.identical)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('7b4e20f0-a21a-4355-a72c-3ec97dafd2de','a9aeea80-6c7e-4ef2-a8e5-4f53497a5004','79b41663-3145-4e99-ae9a-129768caf02b','../lite/tree/../notebooks/index.html?path=07745257_4eee_472f_a19c_4dd373540960.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> 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
```

```pycon
>>> a.equals(b)
True
>>> a.equals(c)
False
>>> a.equals(d)
False
```

<div id="79b41663-3145-4e99-ae9a-129768caf02b" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('7b4e20f0-a21a-4355-a72c-3ec97dafd2de','79b41663-3145-4e99-ae9a-129768caf02b')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('7b4e20f0-a21a-4355-a72c-3ec97dafd2de','79b41663-3145-4e99-ae9a-129768caf02b')">Open In Tab</button></div><div id="a9aeea80-6c7e-4ef2-a8e5-4f53497a5004" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
