Skip to content

Commit 047063b

Browse files
committed
Fix io.rst.
1 parent 37c9223 commit 047063b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

doc/io.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ We can save a Dataset to disk using the
4949

5050
.. ipython:: python
5151
52+
ds = xr.Dataset({'foo': (('x', 'y'), np.random.rand(4, 5))},
53+
coords={'x': [10, 20, 30, 40],
54+
'y': pd.date_range('2000-01-01', periods=5),
55+
'z': ('x', list('abcd'))})
56+
5257
ds.to_netcdf('saved_on_disk.nc')
5358
5459
By default, the file is saved as netCDF4 (assuming netCDF4-Python is
@@ -59,7 +64,7 @@ the ``format`` and ``engine`` arguments.
5964

6065
Using the `h5netcdf <https://github.com/shoyer/h5netcdf>`_ package
6166
by passing ``engine='h5netcdf'`` to :py:meth:`~xarray.open_dataset` can
62-
be quicker than the default ``engine='netcdf4'`` that uses the
67+
sometimes be quicker than the default ``engine='netcdf4'`` that uses the
6368
`netCDF4 <https://github.com/Unidata/netcdf4-python>`_ package.
6469

6570

@@ -171,8 +176,6 @@ will remove encoding information.
171176
:suppress:
172177
173178
ds_disk.close()
174-
import os
175-
os.remove('saved_on_disk.nc')
176179
177180
.. _io.netcdf.writing_encoded:
178181

@@ -459,11 +462,6 @@ module:
459462
460463
import pickle
461464
462-
ds = xr.Dataset({'foo': (('x', 'y'), np.random.rand(4, 5))},
463-
coords={'x': [10, 20, 30, 40],
464-
'y': pd.date_range('2000-01-01', periods=5),
465-
'z': ('x', list('abcd'))})
466-
467465
# use the highest protocol (-1) because it is way faster than the default
468466
# text based pickle format
469467
pkl = pickle.dumps(ds, protocol=-1)
@@ -523,6 +521,12 @@ To export just the dataset schema, without the data itself, use the
523521
This can be useful for generating indices of dataset contents to expose to
524522
search indices or other automated data discovery tools.
525523

524+
.. ipython:: python
525+
:suppress:
526+
527+
import os
528+
os.remove('saved_on_disk.nc')
529+
526530
.. _io.rasterio:
527531

528532
Rasterio

0 commit comments

Comments
 (0)