Skip to content

Commit 8df0ca4

Browse files
committed
Fix io.rst.
1 parent b1dfc66 commit 8df0ca4

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
@@ -51,6 +51,11 @@ We can save a Dataset to disk using the
5151

5252
.. ipython:: python
5353
54+
ds = xr.Dataset({'foo': (('x', 'y'), np.random.rand(4, 5))},
55+
coords={'x': [10, 20, 30, 40],
56+
'y': pd.date_range('2000-01-01', periods=5),
57+
'z': ('x', list('abcd'))})
58+
5459
ds.to_netcdf('saved_on_disk.nc')
5560
5661
By default, the file is saved as netCDF4 (assuming netCDF4-Python is
@@ -61,7 +66,7 @@ the ``format`` and ``engine`` arguments.
6166

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

6772

@@ -191,8 +196,6 @@ will remove encoding information.
191196
:suppress:
192197
193198
ds_disk.close()
194-
import os
195-
os.remove('saved_on_disk.nc')
196199
197200
198201
.. _combining multiple files:
@@ -633,11 +636,6 @@ module:
633636
634637
import pickle
635638
636-
ds = xr.Dataset({'foo': (('x', 'y'), np.random.rand(4, 5))},
637-
coords={'x': [10, 20, 30, 40],
638-
'y': pd.date_range('2000-01-01', periods=5),
639-
'z': ('x', list('abcd'))})
640-
641639
# use the highest protocol (-1) because it is way faster than the default
642640
# text based pickle format
643641
pkl = pickle.dumps(ds, protocol=-1)
@@ -697,6 +695,12 @@ To export just the dataset schema, without the data itself, use the
697695
This can be useful for generating indices of dataset contents to expose to
698696
search indices or other automated data discovery tools.
699697

698+
.. ipython:: python
699+
:suppress:
700+
701+
import os
702+
os.remove('saved_on_disk.nc')
703+
700704
.. _io.rasterio:
701705

702706
Rasterio

0 commit comments

Comments
 (0)