@@ -64,15 +64,18 @@ dimension:
6464
6565.. jupyter-execute ::
6666
67- xr.concat([da.isel(x=0), da.isel(x=1)], "new_dim")
67+ da0 = da.isel(x=0, drop=True)
68+ da1 = da.isel(x=1, drop=True)
69+
70+ xr.concat([da0, da1], "new_dim")
6871
6972The second argument to ``concat `` can also be an :py:class: `~pandas.Index ` or
7073:py:class: `~xarray.DataArray ` object as well as a string, in which case it is
7174used to label the values along the new dimension:
7275
7376.. jupyter-execute ::
7477
75- xr.concat([da.isel(x=0), da.isel(x=1) ], pd.Index([-90, -100], name="new_dim"))
78+ xr.concat([da0, da1 ], pd.Index([-90, -100], name="new_dim"))
7679
7780Of course, ``concat `` also works on ``Dataset `` objects:
7881
@@ -87,6 +90,12 @@ between datasets. With the default parameters, xarray will load some coordinate
8790variables into memory to compare them between datasets. This may be prohibitively
8891expensive if you are manipulating your dataset lazily using :ref: `dask `.
8992
93+ .. note ::
94+
95+ In a future version of xarray the default values for many of these options
96+ will change. You can opt into the new default values early using
97+ ``xr.set_options(use_new_combine_kwarg_defaults=True) ``.
98+
9099.. _merge :
91100
92101Merge
@@ -109,10 +118,18 @@ If you merge another dataset (or a dictionary including data array objects), by
109118default the resulting dataset will be aligned on the **union ** of all index
110119coordinates:
111120
121+ .. note ::
122+
123+ In a future version of xarray the default value for ``join `` and ``compat ``
124+ will change. This change will mean that xarray will no longer attempt
125+ to align the indices of the merged dataset. You can opt into the new default
126+ values early using ``xr.set_options(use_new_combine_kwarg_defaults=True) ``.
127+ Or explicitly set ``join='outer' `` to preserve old behavior.
128+
112129.. jupyter-execute ::
113130
114131 other = xr.Dataset({"bar": ("x", [1, 2, 3, 4]), "x": list("abcd")})
115- xr.merge([ds, other])
132+ xr.merge([ds, other], join="outer" )
116133
117134This ensures that ``merge `` is non-destructive. ``xarray.MergeError `` is raised
118135if you attempt to merge two variables with the same name but different values:
@@ -123,6 +140,16 @@ if you attempt to merge two variables with the same name but different values:
123140 xr.merge([ds, ds + 1])
124141
125142
143+ .. note ::
144+
145+ In a future version of xarray the default value for ``compat `` will change
146+ from ``compat='no_conflicts' `` to ``compat='override' ``. In this scenario
147+ the values in the first object override all the values in other objects.
148+
149+ .. jupyter-execute ::
150+
151+ xr.merge([ds, ds + 1], compat="override")
152+
126153The same non-destructive merging between ``DataArray `` index coordinates is
127154used in the :py:class: `~xarray.Dataset ` constructor:
128155
@@ -156,6 +183,11 @@ For datasets, ``ds0.combine_first(ds1)`` works similarly to
156183there are conflicting values in variables to be merged, whereas
157184``.combine_first `` defaults to the calling object's values.
158185
186+ .. note ::
187+
188+ In a future version of xarray the default options for ``xr.merge `` will change
189+ such that the behavior matches ``combine_first ``.
190+
159191.. _update :
160192
161193Update
@@ -248,7 +280,7 @@ coordinates as long as any non-missing values agree or are disjoint:
248280
249281 ds1 = xr.Dataset({"a": ("x", [10, 20, 30, np.nan])}, {"x": [1, 2, 3, 4]})
250282 ds2 = xr.Dataset({"a": ("x", [np.nan, 30, 40, 50])}, {"x": [2, 3, 4, 5]})
251- xr.merge([ds1, ds2], compat="no_conflicts")
283+ xr.merge([ds1, ds2], join="outer", compat="no_conflicts")
252284
253285Note that due to the underlying representation of missing values as floating
254286point numbers (``NaN ``), variable data type is not always preserved when merging
@@ -311,12 +343,11 @@ coordinates, not on their position in the list passed to ``combine_by_coords``.
311343
312344.. jupyter-execute ::
313345
314-
315346 x1 = xr.DataArray(name="foo", data=np.random.randn(3), coords=[("x", [0, 1, 2])])
316347 x2 = xr.DataArray(name="foo", data=np.random.randn(3), coords=[("x", [3, 4, 5])])
317348 xr.combine_by_coords([x2, x1])
318349
319- These functions can be used by :py:func: `~xarray.open_mfdataset ` to open many
350+ These functions are used by :py:func: `~xarray.open_mfdataset ` to open many
320351files as one dataset. The particular function used is specified by setting the
321352argument ``'combine' `` to ``'by_coords' `` or ``'nested' ``. This is useful for
322353situations where your data is split across many files in multiple locations,
0 commit comments