@@ -64,15 +64,18 @@ dimension:
64
64
65
65
.. jupyter-execute ::
66
66
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")
68
71
69
72
The second argument to ``concat `` can also be an :py:class: `~pandas.Index ` or
70
73
:py:class: `~xarray.DataArray ` object as well as a string, in which case it is
71
74
used to label the values along the new dimension:
72
75
73
76
.. jupyter-execute ::
74
77
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"))
76
79
77
80
Of course, ``concat `` also works on ``Dataset `` objects:
78
81
@@ -87,6 +90,12 @@ between datasets. With the default parameters, xarray will load some coordinate
87
90
variables into memory to compare them between datasets. This may be prohibitively
88
91
expensive if you are manipulating your dataset lazily using :ref: `dask `.
89
92
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
+
90
99
.. _merge :
91
100
92
101
Merge
@@ -109,10 +118,18 @@ If you merge another dataset (or a dictionary including data array objects), by
109
118
default the resulting dataset will be aligned on the **union ** of all index
110
119
coordinates:
111
120
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
+
112
129
.. jupyter-execute ::
113
130
114
131
other = xr.Dataset({"bar": ("x", [1, 2, 3, 4]), "x": list("abcd")})
115
- xr.merge([ds, other])
132
+ xr.merge([ds, other], join="outer" )
116
133
117
134
This ensures that ``merge `` is non-destructive. ``xarray.MergeError `` is raised
118
135
if 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:
123
140
xr.merge([ds, ds + 1])
124
141
125
142
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
+
126
153
The same non-destructive merging between ``DataArray `` index coordinates is
127
154
used in the :py:class: `~xarray.Dataset ` constructor:
128
155
@@ -156,6 +183,11 @@ For datasets, ``ds0.combine_first(ds1)`` works similarly to
156
183
there are conflicting values in variables to be merged, whereas
157
184
``.combine_first `` defaults to the calling object's values.
158
185
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
+
159
191
.. _update :
160
192
161
193
Update
@@ -248,7 +280,7 @@ coordinates as long as any non-missing values agree or are disjoint:
248
280
249
281
ds1 = xr.Dataset({"a": ("x", [10, 20, 30, np.nan])}, {"x": [1, 2, 3, 4]})
250
282
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")
252
284
253
285
Note that due to the underlying representation of missing values as floating
254
286
point 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``.
311
343
312
344
.. jupyter-execute ::
313
345
314
-
315
346
x1 = xr.DataArray(name="foo", data=np.random.randn(3), coords=[("x", [0, 1, 2])])
316
347
x2 = xr.DataArray(name="foo", data=np.random.randn(3), coords=[("x", [3, 4, 5])])
317
348
xr.combine_by_coords([x2, x1])
318
349
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
320
351
files as one dataset. The particular function used is specified by setting the
321
352
argument ``'combine' `` to ``'by_coords' `` or ``'nested' ``. This is useful for
322
353
situations where your data is split across many files in multiple locations,
0 commit comments