Skip to content

Commit 7dbdd4a

Browse files
committed
Minimal docs update
1 parent f1649b8 commit 7dbdd4a

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

doc/user-guide/combining.rst

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ new dimension by stacking lower dimensional arrays together:
4343

4444
.. ipython:: python
4545
46-
da.sel(x="a")
4746
xr.concat([da.isel(x=0), da.isel(x=1)], "x")
4847
4948
If the second argument to ``concat`` is a new dimension name, the arrays will
@@ -52,15 +51,18 @@ dimension:
5251

5352
.. ipython:: python
5453
55-
xr.concat([da.isel(x=0), da.isel(x=1)], "new_dim")
54+
da0 = da.isel(x=0).drop_vars("x")
55+
da1 = da.isel(x=1).drop_vars("x")
56+
57+
xr.concat([da0, da1], "new_dim")
5658
5759
The second argument to ``concat`` can also be an :py:class:`~pandas.Index` or
5860
:py:class:`~xarray.DataArray` object as well as a string, in which case it is
5961
used to label the values along the new dimension:
6062

6163
.. ipython:: python
6264
63-
xr.concat([da.isel(x=0), da.isel(x=1)], pd.Index([-90, -100], name="new_dim"))
65+
xr.concat([da0, da1], pd.Index([-90, -100], name="new_dim"))
6466
6567
Of course, ``concat`` also works on ``Dataset`` objects:
6668

@@ -75,6 +77,12 @@ between datasets. With the default parameters, xarray will load some coordinate
7577
variables into memory to compare them between datasets. This may be prohibitively
7678
expensive if you are manipulating your dataset lazily using :ref:`dask`.
7779

80+
.. note::
81+
82+
The default values for many of these options will be changing in a future
83+
version of xarray. You can opt into the new default values early using
84+
``xr.set_options(use_new_combine_kwarg_defaults=True)``.
85+
7886
.. _merge:
7987

8088
Merge
@@ -94,10 +102,18 @@ If you merge another dataset (or a dictionary including data array objects), by
94102
default the resulting dataset will be aligned on the **union** of all index
95103
coordinates:
96104

105+
.. note::
106+
107+
The default value for ``join`` and ``compat`` will be changing in a future
108+
version of xarray. This change will mean that the resulting dataset will be
109+
not be aligned. You can opt into the new default values early using
110+
``xr.set_options(use_new_combine_kwarg_defaults=True)``. Or explicitly set
111+
``join='outer'`` to preserve old behavior.
112+
97113
.. ipython:: python
98114
99115
other = xr.Dataset({"bar": ("x", [1, 2, 3, 4]), "x": list("abcd")})
100-
xr.merge([ds, other])
116+
xr.merge([ds, other], join="outer")
101117
102118
This ensures that ``merge`` is non-destructive. ``xarray.MergeError`` is raised
103119
if you attempt to merge two variables with the same name but different values:
@@ -114,6 +130,16 @@ if you attempt to merge two variables with the same name but different values:
114130
array([[ 1.4691123 , 0.71713666, -0.5090585 ],
115131
[-0.13563237, 2.21211203, 0.82678535]])
116132

133+
.. note::
134+
135+
In the future the default value for ``compat`` will change from
136+
``compat='no_conflicts'`` to ``compat='override'``. In this scenario the
137+
values in the first object override all the values in other objects.
138+
139+
.. ipython:: python
140+
141+
xr.merge([ds, ds + 1], compat="override")
142+
117143
The same non-destructive merging between ``DataArray`` index coordinates is
118144
used in the :py:class:`~xarray.Dataset` constructor:
119145

@@ -144,6 +170,11 @@ For datasets, ``ds0.combine_first(ds1)`` works similarly to
144170
there are conflicting values in variables to be merged, whereas
145171
``.combine_first`` defaults to the calling object's values.
146172

173+
.. note::
174+
175+
In a future version of xarray the default options for ``xr.merge`` will change
176+
such that the behavior matches ``combine_first``.
177+
147178
.. _update:
148179

149180
Update
@@ -236,7 +267,7 @@ coordinates as long as any non-missing values agree or are disjoint:
236267
237268
ds1 = xr.Dataset({"a": ("x", [10, 20, 30, np.nan])}, {"x": [1, 2, 3, 4]})
238269
ds2 = xr.Dataset({"a": ("x", [np.nan, 30, 40, 50])}, {"x": [2, 3, 4, 5]})
239-
xr.merge([ds1, ds2], compat="no_conflicts")
270+
xr.merge([ds1, ds2], join="outer", compat="no_conflicts")
240271
241272
Note that due to the underlying representation of missing values as floating
242273
point numbers (``NaN``), variable data type is not always preserved when merging
@@ -295,13 +326,12 @@ they are concatenated in order based on the values in their dimension
295326
coordinates, not on their position in the list passed to ``combine_by_coords``.
296327

297328
.. ipython:: python
298-
:okwarning:
299329
300330
x1 = xr.DataArray(name="foo", data=np.random.randn(3), coords=[("x", [0, 1, 2])])
301331
x2 = xr.DataArray(name="foo", data=np.random.randn(3), coords=[("x", [3, 4, 5])])
302332
xr.combine_by_coords([x2, x1])
303333
304-
These functions can be used by :py:func:`~xarray.open_mfdataset` to open many
334+
These functions are used by :py:func:`~xarray.open_mfdataset` to open many
305335
files as one dataset. The particular function used is specified by setting the
306336
argument ``'combine'`` to ``'by_coords'`` or ``'nested'``. This is useful for
307337
situations where your data is split across many files in multiple locations,

doc/user-guide/terminology.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ complete examples, please consult the relevant documentation.*
217217
)
218218
219219
# combine the datasets
220-
combined_ds = xr.combine_by_coords([ds1, ds2])
220+
combined_ds = xr.combine_by_coords([ds1, ds2], join="outer")
221221
combined_ds
222222
223223
lazy

doc/whats-new.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7925,13 +7925,17 @@ Backwards incompatible changes
79257925
Now, the default always concatenates data variables:
79267926

79277927
.. ipython:: python
7928-
:suppress:
7929-
7930-
ds = xray.Dataset({"x": 0})
7928+
:verbatim:
79317929
7932-
.. ipython:: python
7930+
In [1]: ds = xray.Dataset({"x": 0})
79337931
7934-
xray.concat([ds, ds], dim="y")
7932+
In [2]: xray.concat([ds, ds], dim="y")
7933+
Out[2]:
7934+
<xarray.Dataset> Size: 16B
7935+
Dimensions: (y: 2)
7936+
Dimensions without coordinates: y
7937+
Data variables:
7938+
x (y) int64 16B 0 0
79357939
79367940
To obtain the old behavior, supply the argument ``concat_over=[]``.
79377941

0 commit comments

Comments
 (0)