MCPcopy
hub / github.com/pydata/xarray / concat

Method concat

xarray/core/variable.py:1788–1875  ·  view source on GitHub ↗

Concatenate variables along a new or existing dimension. Parameters ---------- variables : iterable of Variable Arrays to stack together. Each variable is expected to have matching dimensions and shape except for along the stacked dimensio

(
        cls,
        variables,
        dim="concat_dim",
        positions=None,
        shortcut=False,
        combine_attrs="override",
    )

Source from the content-addressed store, hash-verified

1786
1787 @classmethod
1788 def concat(
1789 cls,
1790 variables,
1791 dim="concat_dim",
1792 positions=None,
1793 shortcut=False,
1794 combine_attrs="override",
1795 ):
1796 """Concatenate variables along a new or existing dimension.
1797
1798 Parameters
1799 ----------
1800 variables : iterable of Variable
1801 Arrays to stack together. Each variable is expected to have
1802 matching dimensions and shape except for along the stacked
1803 dimension.
1804 dim : str or DataArray, optional
1805 Name of the dimension to stack along. This can either be a new
1806 dimension name, in which case it is added along axis=0, or an
1807 existing dimension name, in which case the location of the
1808 dimension is unchanged. Where to insert the new dimension is
1809 determined by the first variable.
1810 positions : None or list of array-like, optional
1811 List of integer arrays which specifies the integer positions to
1812 which to assign each dataset along the concatenated dimension.
1813 If not supplied, objects are concatenated in the provided order.
1814 shortcut : bool, optional
1815 This option is used internally to speed-up groupby operations.
1816 If `shortcut` is True, some checks of internal consistency between
1817 arrays to concatenate are skipped.
1818 combine_attrs : {"drop", "identical", "no_conflicts", "drop_conflicts", \
1819 "override"}, default: "override"
1820 String indicating how to combine attrs of the objects being merged:
1821
1822 - "drop": empty attrs on returned Dataset.
1823 - "identical": all attrs must be the same on every object.
1824 - "no_conflicts": attrs from all objects are combined, any that have
1825 the same name must also have the same value.
1826 - "drop_conflicts": attrs from all objects are combined, any that have
1827 the same name but different values are dropped.
1828 - "override": skip comparing and copy attrs from the first dataset to
1829 the result.
1830
1831 Returns
1832 -------
1833 stacked : Variable
1834 Concatenated Variable formed by stacking all the supplied variables
1835 along the given dimension.
1836 """
1837 from xarray.structure.merge import merge_attrs
1838
1839 if not isinstance(dim, str):
1840 (dim,) = dim.dims
1841
1842 # can't do this lazily: we need to loop through variables at least
1843 # twice
1844 variables = list(variables)
1845 first_var = variables[0]

Callers 1

concatFunction · 0.45

Calls 3

merge_attrsFunction · 0.90
get_axis_numMethod · 0.45
stackMethod · 0.45

Tested by

no test coverage detected