Skip to content

Commit 1f81338

Browse files
keewisdcherian
authored andcommitted
Fixes to the resample docs (#3400)
* 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
1 parent 3f9069b commit 1f81338

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

doc/whats-new.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ What's New
1818
v0.14.1 (unreleased)
1919
--------------------
2020

21+
Documentation
22+
~~~~~~~~~~~~~
23+
24+
- Fix the documentation of :py:meth:`DataArray.resample` and
25+
:py:meth:`Dataset.resample` and explicitly state that a
26+
datetime-like dimension is required. (:pull:`3400`)
27+
By `Justus Magin <https://github.com/keewis>`_.
2128

2229
.. _whats-new.0.14.0:
2330

xarray/core/common.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,16 @@ def resample(
914914
):
915915
"""Returns a Resample object for performing resampling operations.
916916
917-
Handles both downsampling and upsampling. If any intervals contain no
918-
values from the original object, they will be given the value ``NaN``.
917+
Handles both downsampling and upsampling. The resampled
918+
dimension must be a datetime-like coordinate. If any intervals
919+
contain no values from the original object, they will be given
920+
the value ``NaN``.
919921
920922
Parameters
921923
----------
922924
indexer : {dim: freq}, optional
923-
Mapping from the dimension name to resample frequency.
925+
Mapping from the dimension name to resample frequency. The
926+
dimension must be datetime-like.
924927
skipna : bool, optional
925928
Whether to skip missing values when aggregating in downsampling.
926929
closed : 'left' or 'right', optional
@@ -978,12 +981,18 @@ def resample(
978981
* time (time) datetime64[ns] 1999-12-15 1999-12-16 1999-12-17 ...
979982
980983
Limit scope of upsampling method
984+
981985
>>> da.resample(time='1D').nearest(tolerance='1D')
982986
<xarray.DataArray (time: 337)>
983987
array([ 0., 0., nan, ..., nan, 11., 11.])
984988
Coordinates:
985989
* time (time) datetime64[ns] 1999-12-15 1999-12-16 ... 2000-11-15
986990
991+
See Also
992+
--------
993+
pandas.Series.resample
994+
pandas.DataFrame.resample
995+
987996
References
988997
----------
989998

0 commit comments

Comments
 (0)