Skip to content

DOC: Updated Resampler.mean docstring to have its own docstring #48980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this versionadded?

Copy link
Contributor Author

@donghyyun donghyyun Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phofl In var, std method, numeric_only versionadded is written. So I thought mean method also need versionadded. If it is wrong, I will fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var and std did not support this prior to 1.5, but this function was consistent with the groupby op that already supported this before. So you can remove it

Copy link
Contributor Author

@donghyyun donghyyun Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for comments. I removed it.


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,
Expand Down Expand Up @@ -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"))
Expand Down