Skip to content

Commit

Permalink
DOC: Add Dataset.drop_dims() documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kmsquire committed Mar 3, 2019
1 parent 3f4552d commit 2cc10bd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Dataset contents
Dataset.swap_dims
Dataset.expand_dims
Dataset.drop
Dataset.drop_dims
Dataset.set_coords
Dataset.reset_coords

Expand Down
7 changes: 7 additions & 0 deletions doc/data-structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ operations keep around coordinates:
list(ds[['x']])
list(ds.drop('temperature'))
To remove a dimension, you can use :py:meth:`~xarray.Dataset.drop_dims` method.
Any variables using that dimension are dropped:

.. ipython:: python
ds.drop_dims('time')
As an alternate to dictionary-like modifications, you can use
:py:meth:`~xarray.Dataset.assign` and :py:meth:`~xarray.Dataset.assign_coords`.
These methods return a new dataset with additional (or replaced) or values:
Expand Down
11 changes: 9 additions & 2 deletions doc/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ arrays). However, you can do normal indexing with dimension names:
Using indexing to *assign* values to a subset of dataset (e.g.,
``ds[dict(space=0)] = 1``) is not yet supported.

Dropping labels
---------------
Dropping labels and dimensions
------------------------------

The :py:meth:`~xarray.Dataset.drop` method returns a new object with the listed
index labels along a dimension dropped:
Expand All @@ -241,6 +241,13 @@ index labels along a dimension dropped:
``drop`` is both a ``Dataset`` and ``DataArray`` method.

Use :py:meth:`~xarray.Dataset.drop_dims` to drop a full dimension from a Dataset.
Any variables with these dimensions are also dropped:

.. ipython:: python
ds.drop_dims('time')
.. _masking with where:

Expand Down
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ Enhancements
serialization warnings raised if dates from a standard calendar are found to
be outside the :py:class:`pandas.Timestamp`-valid range (:issue:`2754`). By
`Spencer Clark <https://github.com/spencerkclark>`_.

- Added :py:meth:`~xarray.Dataset.drop_dims` (:issue:`1949`).
By `Kevin Squire <https://github.com/kmsquire>`_.

Bug fixes
~~~~~~~~~
Expand Down

0 comments on commit 2cc10bd

Please sign in to comment.