From 008c203761618d5070166d4c72b5fd6f80a16125 Mon Sep 17 00:00:00 2001 From: Keewis Date: Tue, 15 Oct 2019 14:47:05 +0200 Subject: [PATCH 1/7] add a missing newline to make sphinx detect the code block --- xarray/core/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xarray/core/common.py b/xarray/core/common.py index 8313247c743..29fb834ca5a 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -978,6 +978,7 @@ 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') array([ 0., 0., nan, ..., nan, 11., 11.]) From 2fcedffe9f16d2eb55fda729aa973a06ad097f57 Mon Sep 17 00:00:00 2001 From: Keewis Date: Tue, 15 Oct 2019 14:48:51 +0200 Subject: [PATCH 2/7] update the link to the pandas documentation --- xarray/core/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/common.py b/xarray/core/common.py index 29fb834ca5a..eb9f24fb8db 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -988,7 +988,7 @@ def resample( References ---------- - .. [1] http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases + .. [1] https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases """ # TODO support non-string indexer after removing the old API. From efc6a9ce14bb6166438110d963d71d043609a5a7 Mon Sep 17 00:00:00 2001 From: Keewis Date: Tue, 15 Oct 2019 14:50:11 +0200 Subject: [PATCH 3/7] explicitly state that this only works with datetime dimensions --- xarray/core/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xarray/core/common.py b/xarray/core/common.py index eb9f24fb8db..e9ff400a6d2 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -920,7 +920,8 @@ def resample( 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 From 01640c624e394b819a96d082f5ae3515e16b5f8e Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 16 Oct 2019 17:21:54 +0200 Subject: [PATCH 4/7] also put the datetime dim requirement into the function description --- xarray/core/common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xarray/core/common.py b/xarray/core/common.py index e9ff400a6d2..c01ff0dd54e 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -914,8 +914,10 @@ 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 ---------- From 95f3808d51e0d2b6738146bf802451dc548c6f7d Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 16 Oct 2019 18:18:24 +0200 Subject: [PATCH 5/7] add Series.resample and DataFrame.resample as reference --- xarray/core/common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xarray/core/common.py b/xarray/core/common.py index c01ff0dd54e..4e1e854a960 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -991,7 +991,12 @@ def resample( References ---------- - .. [1] https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases + .. [1] http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases + + See Also + -------- + pandas.Series.resample + pandas.DataFrame.resample """ # TODO support non-string indexer after removing the old API. From 2ea4a3c876ba33e010ab60dd3d7e19de7b31fb46 Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 16 Oct 2019 20:40:47 +0200 Subject: [PATCH 6/7] add the changes to whats-new.rst --- doc/whats-new.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 9e14120aeb3..2202c91408b 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -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 `_. .. _whats-new.0.14.0: From ce79ef96b1a9832c1661762748f3ebea831856a1 Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 16 Oct 2019 20:48:42 +0200 Subject: [PATCH 7/7] move references to the bottom of the docstring --- xarray/core/common.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xarray/core/common.py b/xarray/core/common.py index 4e1e854a960..a762f7fbed9 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -988,15 +988,15 @@ def resample( Coordinates: * time (time) datetime64[ns] 1999-12-15 1999-12-16 ... 2000-11-15 - References - ---------- - - .. [1] http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases - See Also -------- pandas.Series.resample pandas.DataFrame.resample + + References + ---------- + + .. [1] http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases """ # TODO support non-string indexer after removing the old API.