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: diff --git a/xarray/core/common.py b/xarray/core/common.py index 8313247c743..a762f7fbed9 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -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 @@ -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') 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 ----------