Dataset.merge(other, inplace=None, overwrite_vars=frozenset({}), compat='no_conflicts', join='outer', fill_value=<NA>)

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.

  • other (Dataset or mapping) – Dataset or variables to merge with this dataset.

  • overwrite_vars (hashable or iterable of hashable, optional) – If provided, update variables of these name(s) without checking for conflicts in this dataset.

  • compat ({"broadcast_equals", "equals", "identical", "no_conflicts"}, optional) – String indicating how to compare variables of the same name for potential conflicts:

    • ‘broadcast_equals’: all values must be equal when variables are broadcast against each other to ensure common dimensions.

    • ‘equals’: all values and dimensions must be the same.

    • ‘identical’: all values, dimensions and attributes must be the same.

    • ‘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.

  • join ({"outer", "inner", "left", "right", "exact"}, optional) – 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

  • fill_value (scalar or dict-like, optional) – Value to use for newly missing values. If a dict-like, maps variable names (including coordinates) to fill values.


merged – Merged dataset.

Return type



MergeError – If any variables conflict (see compat).