Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to the resample docs #3400

Merged
merged 7 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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