From 352153396c3588b794c1a2b438aa5ee381ebc4b1 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 5 Apr 2023 16:48:52 +0200 Subject: [PATCH 1/3] [DOC] resample and then apply func on time+other variables: --- doc/user-guide/time-series.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/user-guide/time-series.rst b/doc/user-guide/time-series.rst index d2e15adeba7..f413d83876d 100644 --- a/doc/user-guide/time-series.rst +++ b/doc/user-guide/time-series.rst @@ -224,7 +224,14 @@ resampling group: .. ipython:: python ds.resample(time="6H").reduce(np.mean) + +You can also resample on time while applying a reduction function on time +and on other variables: +.. code-block:: python + + ds.resample(time="6H").mean(dim=['time', 'latitude', 'longitude']) + For upsampling, xarray provides six methods: ``asfreq``, ``ffill``, ``bfill``, ``pad``, ``nearest`` and ``interpolate``. ``interpolate`` extends ``scipy.interpolate.interp1d`` and supports all of its schemes. All of these resampling operations work on both From 12e50430526a12466e60628709b42af462410796 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 14:56:21 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/user-guide/time-series.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/user-guide/time-series.rst b/doc/user-guide/time-series.rst index f413d83876d..20e2ea87597 100644 --- a/doc/user-guide/time-series.rst +++ b/doc/user-guide/time-series.rst @@ -224,14 +224,14 @@ resampling group: .. ipython:: python ds.resample(time="6H").reduce(np.mean) - -You can also resample on time while applying a reduction function on time + +You can also resample on time while applying a reduction function on time and on other variables: .. code-block:: python - ds.resample(time="6H").mean(dim=['time', 'latitude', 'longitude']) - + ds.resample(time="6H").mean(dim=["time", "latitude", "longitude"]) + For upsampling, xarray provides six methods: ``asfreq``, ``ffill``, ``bfill``, ``pad``, ``nearest`` and ``interpolate``. ``interpolate`` extends ``scipy.interpolate.interp1d`` and supports all of its schemes. All of these resampling operations work on both From 0dea34378b191b126ac437af2e453603119ef549 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 5 Apr 2023 19:55:30 -0600 Subject: [PATCH 3/3] Update doc/user-guide/time-series.rst --- doc/user-guide/time-series.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/user-guide/time-series.rst b/doc/user-guide/time-series.rst index 20e2ea87597..54d5dd764ae 100644 --- a/doc/user-guide/time-series.rst +++ b/doc/user-guide/time-series.rst @@ -225,8 +225,8 @@ resampling group: ds.resample(time="6H").reduce(np.mean) -You can also resample on time while applying a reduction function on time -and on other variables: +You can also resample on the time dimension while applying reducing along other dimensions at the same time +by specifying the `dim` keyword argument .. code-block:: python