From f1e03dabd5e1caf7397c29d14f32a604108a31de 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..748baab9fdf40 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -983,6 +983,30 @@ def asfreq(self, fill_value=None): DataFrame.asfreq: Convert TimeSeries to specified frequency. """ 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, @@ -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 6ae6ca8dad5ce0bc8f974c50d3f28e3d4f2f7e0d Mon Sep 17 00:00:00 2001 From: donghyyun Date: Sat, 1 Oct 2022 16:26:59 +0900 Subject: [PATCH 2/2] revised to pass pre-commit --- pandas/core/resample.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 748baab9fdf40..ff83514c80f4e 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -983,7 +983,7 @@ def asfreq(self, fill_value=None): DataFrame.asfreq: Convert TimeSeries to specified frequency. """ return self._upsample("asfreq", fill_value=fill_value) - + def mean( self, numeric_only: bool | lib.NoDefault = lib.no_default,