# xarray.DataArray.equals

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

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`](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('471b9030-4b4f-46bf-91ec-4af5e8e9a6e3','ff86fe74-4da0-4a4b-b335-41cd68d3125e','bc8cbf8b-1222-468b-8224-f1fb5e5180e0','../lite/tree/../notebooks/index.html?path=17c58845_2de4_49aa_8c30_13176ead9261.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="bc8cbf8b-1222-468b-8224-f1fb5e5180e0" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('471b9030-4b4f-46bf-91ec-4af5e8e9a6e3','bc8cbf8b-1222-468b-8224-f1fb5e5180e0')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('471b9030-4b4f-46bf-91ec-4af5e8e9a6e3','bc8cbf8b-1222-468b-8224-f1fb5e5180e0')">Open In Tab</button></div><div id="ff86fe74-4da0-4a4b-b335-41cd68d3125e" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
