xarray.concat

xarray.concat(objs, dim=None, data_vars='all', coords='different', compat='equals', positions=None, indexers=None, mode=None, concat_over=None, fill_value=<NA>)

Concatenate xarray objects along a new or existing dimension.

Parameters
objssequence of Dataset and DataArray objects

xarray objects to concatenate together. Each object is expected to consist of variables and coordinates with matching shapes except for along the concatenated dimension.

dimstr or DataArray or pandas.Index

Name of the dimension to concatenate along. This can either be a new dimension name, in which case it is added along axis=0, or an existing dimension name, in which case the location of the dimension is unchanged. If dimension is provided as a DataArray or Index, its name is used as the dimension to concatenate along and the values are added as a coordinate.

data_vars{‘minimal’, ‘different’, ‘all’ or list of str}, optional
These data variables will be concatenated together:
  • ‘minimal’: Only data variables in which the dimension already appears are included.

  • ‘different’: Data variables which are not equal (ignoring attributes) across all datasets are also concatenated (as well as all for which dimension already appears). Beware: this option may load the data payload of data variables into memory if they are not already loaded.

  • ‘all’: All data variables will be concatenated.

  • list of str: The listed data variables will be concatenated, in addition to the ‘minimal’ data variables.

If objects are DataArrays, data_vars must be ‘all’.

coords{‘minimal’, ‘different’, ‘all’ or list of str}, optional
These coordinate variables will be concatenated together:
  • ‘minimal’: Only coordinates in which the dimension already appears are included.

  • ‘different’: Coordinates which are not equal (ignoring attributes) across all datasets are also concatenated (as well as all for which dimension already appears). Beware: this option may load the data payload of coordinate variables into memory if they are not already loaded.

  • ‘all’: All coordinate variables will be concatenated, except those corresponding to other dimensions.

  • list of str: The listed coordinate variables will be concatenated, in addition the ‘minimal’ coordinates.

compat{‘equals’, ‘identical’}, optional

String indicating how to compare non-concatenated variables and dataset global attributes for potential conflicts. ‘equals’ means that all variable values and dimensions must be the same; ‘identical’ means that variable attributes and global attributes must also be equal.

positionsNone or list of integer arrays, optional

List of integer arrays which specifies the integer positions to which to assign each dataset along the concatenated dimension. If not supplied, objects are concatenated in the provided order.

fill_valuescalar, optional

Value to use for newly missing values

indexers, mode, concat_overdeprecated
Returns
concatenatedtype of objs

See also

merge, auto_combine