From 3a7fe4a3a7bc94abafaff514ed6de831ba990217 Mon Sep 17 00:00:00 2001 From: donghyyun Date: Fri, 30 Sep 2022 13:59:01 +0000 Subject: [PATCH 1/2] DOC: Added mean function as method of Resampler and updated docstring --- pandas/core/resample.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 574c2e5e0f552..ff83514c80f4e 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -984,6 +984,30 @@ def asfreq(self, fill_value=None): """ return self._upsample("asfreq", fill_value=fill_value) + def mean( + self, + numeric_only: bool | lib.NoDefault = lib.no_default, + *args, + **kwargs, + ): + """ + Compute mean of groups, excluding missing values. + + Parameters + ---------- + numeric_only : bool, default False + Include only `float`, `int` or `boolean` data. + + .. versionadded:: 1.5.0 + + Returns + ------- + DataFrame or Series + Mean of values within each group. + """ + nv.validate_resampler_func("mean", args, kwargs) + return self._downsample("mean", numeric_only=numeric_only) + def std( self, ddof: int = 1, @@ -1173,7 +1197,7 @@ def f( # type: ignore[misc] for method in ["sum", "prod", "min", "max", "first", "last"]: _add_downsample_kernel(method, ("numeric_only", "min_count")) -for method in ["mean", "median"]: +for method in ["median"]: _add_downsample_kernel(method, ("numeric_only",)) for method in ["sem"]: _add_downsample_kernel(method, ("ddof", "numeric_only")) From 2f213ea378a0b4387a2692e7ad25c23e71a8d679 Mon Sep 17 00:00:00 2001 From: donghyyun Date: Fri, 7 Oct 2022 14:31:45 +0000 Subject: [PATCH 2/2] removed versionadded --- pandas/core/resample.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/core/resample.py b/pandas/core/resample.py index ff83514c80f4e..cf8c8b7db800b 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -998,8 +998,6 @@ def mean( numeric_only : bool, default False Include only `float`, `int` or `boolean` data. - .. versionadded:: 1.5.0 - Returns ------- DataFrame or Series