Skip to content

Commit

Permalink
added documentation (indexing)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Bovy committed May 30, 2016
1 parent eb7a12e commit 93ef7d2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions doc/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,27 @@ elements that are fully masked:
arr2.where(arr2.y < 2, drop=True)
.. _multi-index indexing:

Multi-index indexing
--------------------

The ``loc`` and ``sel`` methods of ``Dataset`` and ``DataArray`` both accept
dictionaries for indexing on multi-index dimensions:

.. ipython:: python
idx = pd.MultiIndex.from_product([list('abc'), [0, 1]],
names=('one', 'two'))
da_midx = xr.DataArray(range(6), [('x', idx)])
da_midx
da_midx.sel(x={'one': 'a', 'two': 0})
da_midx.loc[{'one': 'a'}, ...]
As shown in the last example above, xarray handles partial selection on
pandas multi-index ; it automatically renames the dimension and replaces the
coordinate when a single index is returned (level drop).

Multi-dimensional indexing
--------------------------

Expand Down

0 comments on commit 93ef7d2

Please sign in to comment.