Skip to content

Commit

Permalink
Fixes to the resample docs (#3400)
Browse files Browse the repository at this point in the history
* add a missing newline to make sphinx detect the code block

* update the link to the pandas documentation

* explicitly state that this only works with datetime dimensions

* also put the datetime dim requirement into the function description

* add Series.resample and DataFrame.resample as reference

* add the changes to whats-new.rst

* move references to the bottom of the docstring
  • Loading branch information
keewis authored and dcherian committed Oct 16, 2019
1 parent 3f9069b commit 1f81338
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ What's New
v0.14.1 (unreleased)
--------------------

Documentation
~~~~~~~~~~~~~

- Fix the documentation of :py:meth:`DataArray.resample` and
:py:meth:`Dataset.resample` and explicitly state that a
datetime-like dimension is required. (:pull:`3400`)
By `Justus Magin <https://github.com/keewis>`_.

.. _whats-new.0.14.0:

Expand Down
15 changes: 12 additions & 3 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,13 +914,16 @@ def resample(
):
"""Returns a Resample object for performing resampling operations.
Handles both downsampling and upsampling. If any intervals contain no
values from the original object, they will be given the value ``NaN``.
Handles both downsampling and upsampling. The resampled
dimension must be a datetime-like coordinate. If any intervals
contain no values from the original object, they will be given
the value ``NaN``.
Parameters
----------
indexer : {dim: freq}, optional
Mapping from the dimension name to resample frequency.
Mapping from the dimension name to resample frequency. The
dimension must be datetime-like.
skipna : bool, optional
Whether to skip missing values when aggregating in downsampling.
closed : 'left' or 'right', optional
Expand Down Expand Up @@ -978,12 +981,18 @@ def resample(
* time (time) datetime64[ns] 1999-12-15 1999-12-16 1999-12-17 ...
Limit scope of upsampling method
>>> da.resample(time='1D').nearest(tolerance='1D')
<xarray.DataArray (time: 337)>
array([ 0., 0., nan, ..., nan, 11., 11.])
Coordinates:
* time (time) datetime64[ns] 1999-12-15 1999-12-16 ... 2000-11-15
See Also
--------
pandas.Series.resample
pandas.DataFrame.resample
References
----------
Expand Down

0 comments on commit 1f81338

Please sign in to comment.