Skip to content

Commit f1e03da

Browse files
committed
DOC: Added mean function as method of Resampler and updated docstring
1 parent f47d82b commit f1e03da

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

pandas/core/resample.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,30 @@ def asfreq(self, fill_value=None):
983983
DataFrame.asfreq: Convert TimeSeries to specified frequency.
984984
"""
985985
return self._upsample("asfreq", fill_value=fill_value)
986+
987+
def mean(
988+
self,
989+
numeric_only: bool | lib.NoDefault = lib.no_default,
990+
*args,
991+
**kwargs,
992+
):
993+
"""
994+
Compute mean of groups, excluding missing values.
995+
996+
Parameters
997+
----------
998+
numeric_only : bool, default False
999+
Include only `float`, `int` or `boolean` data.
1000+
1001+
.. versionadded:: 1.5.0
1002+
1003+
Returns
1004+
-------
1005+
DataFrame or Series
1006+
Mean of values within each group.
1007+
"""
1008+
nv.validate_resampler_func("mean", args, kwargs)
1009+
return self._downsample("mean", numeric_only=numeric_only)
9861010

9871011
def std(
9881012
self,
@@ -1173,7 +1197,7 @@ def f( # type: ignore[misc]
11731197

11741198
for method in ["sum", "prod", "min", "max", "first", "last"]:
11751199
_add_downsample_kernel(method, ("numeric_only", "min_count"))
1176-
for method in ["mean", "median"]:
1200+
for method in ["median"]:
11771201
_add_downsample_kernel(method, ("numeric_only",))
11781202
for method in ["sem"]:
11791203
_add_downsample_kernel(method, ("ddof", "numeric_only"))

0 commit comments

Comments
 (0)