Skip to content

Commit caa00e7

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

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
@@ -973,6 +973,30 @@ def asfreq(self, fill_value=None):
973973
DataFrame.asfreq: Convert TimeSeries to specified frequency.
974974
"""
975975
return self._upsample("asfreq", fill_value=fill_value)
976+
977+
def mean(
978+
self,
979+
numeric_only: bool | lib.NoDefault = lib.no_default,
980+
*args,
981+
**kwargs,
982+
):
983+
"""
984+
Compute mean of groups, excluding missing values.
985+
986+
Parameters
987+
----------
988+
numeric_only : bool, default False
989+
Include only `float`, `int` or `boolean` data.
990+
991+
.. versionadded:: 1.5.0
992+
993+
Returns
994+
-------
995+
DataFrame or Series
996+
Mean of values within each group.
997+
"""
998+
nv.validate_resampler_func("mean", args, kwargs)
999+
return self._downsample("mean", numeric_only=numeric_only)
9761000

9771001
def std(
9781002
self,
@@ -1163,7 +1187,7 @@ def f( # type: ignore[misc]
11631187

11641188
for method in ["sum", "prod", "min", "max", "first", "last"]:
11651189
_add_downsample_kernel(method, ("numeric_only", "min_count"))
1166-
for method in ["mean", "median"]:
1190+
for method in ["median"]:
11671191
_add_downsample_kernel(method, ("numeric_only",))
11681192
for method in ["sem"]:
11691193
_add_downsample_kernel(method, ("ddof", "numeric_only"))

0 commit comments

Comments
 (0)