# xarray.Dataset.merge

#### Dataset.merge(other, overwrite_vars=frozenset({}), compat=no_conflicts, join=outer, fill_value=<NA>, combine_attrs='override')[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataset.py#L5771-L5868)

Merge the arrays of two datasets into a single dataset.

This method generally does not allow for overriding data, with the
exception of attributes, which are ignored on the second dataset.
Variables with the same name are checked for conflicts via the equals
or identical methods.

* **Parameters:**
  * **other** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset) or [mapping](https://docs.python.org/3/glossary.html#term-mapping)) – Dataset or variables to merge with this dataset.
  * **overwrite_vars** ([hashable](../user-guide/terminology.html.md#term-name) or [iterable](https://docs.python.org/3/glossary.html#term-iterable) of [hashable](../user-guide/terminology.html.md#term-name), *optional*) – If provided, update variables of these name(s) without checking for
    conflicts in this dataset.
  * **compat** (`{"identical", "equals", "broadcast_equals", "no_conflicts", "override", "minimal"}`, *default*: `"no_conflicts"`) – String indicating how to compare variables of the same name for
    potential conflicts:
    - ‘identical’: all values, dimensions and attributes must be the
      same.
    - ‘equals’: all values and dimensions must be the same.
    - ‘broadcast_equals’: all values must be equal when variables are
      broadcast against each other to ensure common dimensions.
    - ‘no_conflicts’: only values which are not null in both datasets
      must be equal. The returned dataset then contains the combination
      of all non-null values.
    - ‘override’: skip comparing and pick variable from first dataset
    - ‘minimal’: drop conflicting coordinates
  * **join** (`{"outer", "inner", "left", "right", "exact", "override"}`,                default: `"outer"`) – Method for joining `self` and `other` along shared dimensions:
    - ‘outer’: use the union of the indexes
    - ‘inner’: use the intersection of the indexes
    - ‘left’: use indexes from `self`
    - ‘right’: use indexes from `other`
    - ‘exact’: error instead of aligning non-equal indexes
    - ‘override’: use indexes from `self` that are the same size
      as those of `other` in that dimension
  * **fill_value** ([scalar](../user-guide/terminology.html.md#term-scalar) or [dict-like](https://docs.python.org/3/glossary.html#term-mapping), *optional*) – Value to use for newly missing values. If a dict-like, maps
    variable names (including coordinates) to fill values.
  * **combine_attrs** (`{"drop", "identical", "no_conflicts", "drop_conflicts", "override"}` or [`callable()`](https://docs.python.org/3/builtins/functions.html#callable), *default*: `"override"`) – A callable or a string indicating how to combine attrs of the objects being
    merged:
    - “drop”: empty attrs on returned Dataset.
    - “identical”: all attrs must be the same on every object.
    - “no_conflicts”: attrs from all objects are combined, any that have
      the same name must also have the same value.
    - “drop_conflicts”: attrs from all objects are combined, any that have
      the same name but different values are dropped.
    - “override”: skip comparing and copy attrs from the first dataset to
      the result.

    If a callable, it must expect a sequence of `attrs` dicts and a context object
    as its only parameters.
* **Returns:**
  **merged** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset)) – Merged dataset.
* **Raises:**
  [**MergeError**](xarray.MergeError.html.md#xarray.MergeError) – If any variables conflict (see `compat`).

#### SEE ALSO
[`Dataset.update`](xarray.Dataset.update.html.md#xarray.Dataset.update)
