You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/xarray.rst
+51-6Lines changed: 51 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -283,8 +283,8 @@ The resulting plot would look like this:
283
283
284
284
We can modify the plots by passing additional arguments to the ``.plot()`` method. Since we haven't discussed the plotting library matplotlib in this course, we will not go into further detail here. You can find more information in the `Xarray documentation <https://xarray.pydata.org/en/stable/plotting.html>`_.
285
285
286
-
Exercises 1 (if time allows)
287
-
----------------------------
286
+
Exercises 1
287
+
-----------
288
288
289
289
.. challenge:: Exercises: Xarray-1
290
290
@@ -371,16 +371,61 @@ To save the dataset as a NetCDF file, use the ``.to_netcdf()`` method: ::
371
371
ds.to_netcdf('weather_data.nc')
372
372
373
373
374
-
Exercises 2 (if time allows)
375
-
----------------------------
374
+
Exercises 2
375
+
-----------
376
376
377
377
.. challenge:: Exercises: Xarray-2
378
378
379
-
Provide two 3D numpy arrays and let participants turn them into an Xarray Dataset with the correct dimensions and coordinates.
379
+
Let's change from clmate science to finance for this example. We assume we want to put the stock prices and trading volumes of three companies over ten days in one dataset. Create an Xarray Dataset that uses time and company as dimensions and contains two DataArrays: ``stock_price`` and ``trading_volume``. You can choose the values for the stock prices and trading volumes yourself. As a last thing, add the currency of the stock prices as an attribute to the Dataset.
0 commit comments