# xarray.Dataset.equals

#### Dataset.equals(other)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataset.py#L1707-L1786)

Two Datasets are equal if they have matching variables and
coordinates, all of which are equal.

Datasets can still be equal (like pandas objects) if they have NaN
values in the same locations.

This method is necessary because v1 == v2 for `Dataset`
does element-wise comparisons (like numpy.ndarrays).

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('e8c3ae3f-eafb-4c3f-a8af-f5eee0d83d3e','37f97c60-0caa-4796-a0ac-52c15502a598','1f2192d3-5e9d-45a7-af05-bd21e9de3ba5','../lite/tree/../notebooks/index.html?path=0ee64efa_196c_4cb0_8793_95963b6ce3b5.ipynb','None')">Try it in your browser!</button></div>

# 2D array with shape (1, 3)

```pycon
>>> data = np.array([[1, 2, 3]])
>>> dataset1 = xr.Dataset(
...     {"variable_name": (("space", "time"), data)},
...     coords={"space": [0], "time": [0, 1, 2]},
... )
>>> dataset1
<xarray.Dataset> Size: 56B
Dimensions:        (space: 1, time: 3)
Coordinates:
  * space          (space) int64 8B 0
  * time           (time) int64 24B 0 1 2
Data variables:
    variable_name  (space, time) int64 24B 1 2 3
```

# 2D array with shape (3, 1)

```pycon
>>> data = np.array([[1], [2], [3]])
>>> dataset2 = xr.Dataset(
...     {"variable_name": (("time", "space"), data)},
...     coords={"time": [0, 1, 2], "space": [0]},
... )
>>> dataset2
<xarray.Dataset> Size: 56B
Dimensions:        (time: 3, space: 1)
Coordinates:
  * time           (time) int64 24B 0 1 2
  * space          (space) int64 8B 0
Data variables:
    variable_name  (time, space) int64 24B 1 2 3
>>> dataset1.equals(dataset2)
False
```

```pycon
>>> dataset1.broadcast_equals(dataset2)
True
```

.equals returns True if two Datasets have the same values, dimensions, and coordinates. .broadcast_equals returns True if the
results of broadcasting two Datasets against each other have the same values, dimensions, and coordinates.

Similar for missing values too:

```pycon
>>> ds1 = xr.Dataset(
...     {
...         "temperature": (["x", "y"], [[1, np.nan], [3, 4]]),
...     },
...     coords={"x": [0, 1], "y": [0, 1]},
... )
```

```pycon
>>> ds2 = xr.Dataset(
...     {
...         "temperature": (["x", "y"], [[1, np.nan], [3, 4]]),
...     },
...     coords={"x": [0, 1], "y": [0, 1]},
... )
>>> ds1.equals(ds2)
True
```

<div id="1f2192d3-5e9d-45a7-af05-bd21e9de3ba5" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('e8c3ae3f-eafb-4c3f-a8af-f5eee0d83d3e','1f2192d3-5e9d-45a7-af05-bd21e9de3ba5')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('e8c3ae3f-eafb-4c3f-a8af-f5eee0d83d3e','1f2192d3-5e9d-45a7-af05-bd21e9de3ba5')">Open In Tab</button></div><div id="37f97c60-0caa-4796-a0ac-52c15502a598" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

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