From 7816f2e62ce9e4e48809e5aa256de7e06eee7f1e Mon Sep 17 00:00:00 2001 From: ktseng37 Date: Sat, 7 Sep 2024 18:54:00 -0700 Subject: [PATCH 1/2] update groupby docstrings --- ci/code_checks.sh | 8 -------- pandas/core/groupby/generic.py | 14 ++++++++++++++ pandas/core/groupby/groupby.py | 9 +++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 7ed5103b3b796..adf939d176ad5 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -163,35 +163,27 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.core.groupby.DataFrameGroupBy.agg RT03" \ -i "pandas.core.groupby.DataFrameGroupBy.aggregate RT03" \ -i "pandas.core.groupby.DataFrameGroupBy.boxplot PR07,RT03,SA01" \ - -i "pandas.core.groupby.DataFrameGroupBy.filter SA01" \ -i "pandas.core.groupby.DataFrameGroupBy.get_group RT03,SA01" \ -i "pandas.core.groupby.DataFrameGroupBy.groups SA01" \ -i "pandas.core.groupby.DataFrameGroupBy.hist RT03" \ -i "pandas.core.groupby.DataFrameGroupBy.indices SA01" \ - -i "pandas.core.groupby.DataFrameGroupBy.max SA01" \ - -i "pandas.core.groupby.DataFrameGroupBy.min SA01" \ -i "pandas.core.groupby.DataFrameGroupBy.nth PR02" \ -i "pandas.core.groupby.DataFrameGroupBy.nunique SA01" \ -i "pandas.core.groupby.DataFrameGroupBy.ohlc SA01" \ -i "pandas.core.groupby.DataFrameGroupBy.plot PR02" \ -i "pandas.core.groupby.DataFrameGroupBy.sem SA01" \ - -i "pandas.core.groupby.DataFrameGroupBy.sum SA01" \ -i "pandas.core.groupby.SeriesGroupBy.__iter__ RT03,SA01" \ -i "pandas.core.groupby.SeriesGroupBy.agg RT03" \ -i "pandas.core.groupby.SeriesGroupBy.aggregate RT03" \ - -i "pandas.core.groupby.SeriesGroupBy.filter PR01,SA01" \ -i "pandas.core.groupby.SeriesGroupBy.get_group RT03,SA01" \ -i "pandas.core.groupby.SeriesGroupBy.groups SA01" \ -i "pandas.core.groupby.SeriesGroupBy.indices SA01" \ -i "pandas.core.groupby.SeriesGroupBy.is_monotonic_decreasing SA01" \ -i "pandas.core.groupby.SeriesGroupBy.is_monotonic_increasing SA01" \ - -i "pandas.core.groupby.SeriesGroupBy.max SA01" \ - -i "pandas.core.groupby.SeriesGroupBy.min SA01" \ -i "pandas.core.groupby.SeriesGroupBy.nth PR02" \ -i "pandas.core.groupby.SeriesGroupBy.ohlc SA01" \ -i "pandas.core.groupby.SeriesGroupBy.plot PR02" \ -i "pandas.core.groupby.SeriesGroupBy.sem SA01" \ - -i "pandas.core.groupby.SeriesGroupBy.sum SA01" \ -i "pandas.core.resample.Resampler.__iter__ RT03,SA01" \ -i "pandas.core.resample.Resampler.ffill RT03" \ -i "pandas.core.resample.Resampler.get_group RT03,SA01" \ diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index c112d9b6a4b54..6b1356245b34b 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -603,12 +603,21 @@ def filter(self, func, dropna: bool = True, *args, **kwargs): dropna : bool Drop groups that do not pass the filter. True by default; if False, groups that evaluate False are filled with NaNs. + *args + Additional positional arguments to pass to `func`. + **kwargs + Additional keyword arguments to pass to `func`. Returns ------- Series The filtered subset of the original Series. + See Also + -------- + Series.filter: Filter elements of ungrouped Series. + DataFrameGroupBy.filter : Filter elements of grouped DataFrame. + Notes ----- Functions that mutate the passed object can produce unexpected @@ -1953,6 +1962,11 @@ def filter(self, func, dropna: bool = True, *args, **kwargs) -> DataFrame: DataFrame The filtered subset of the original DataFrame. + See Also + -------- + DataFrame.filter: Filter elements of ungrouped DataFrame. + SeriesGroupBy.filter : Filter elements of grouped Series. + Notes ----- Each subframe is endowed the attribute 'name' in case you need to know diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 79fe78b7e5405..ca05a77d814c1 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -199,6 +199,15 @@ class providing the base-class of operations. Series or DataFrame Computed {fname} of values within each group. +See Also +-------- +Series.min : Return the min of the group values. +DataFrame.min : Return the min of the group values. +Series.max : Return the max of the group values. +DataFrame.max : Return the max of the group values. +Series.sum : Return the sum of the group values. +DataFrame.sum : Return the sum of the group values. + Examples -------- {example} From d0865a1917f3a9c55101695f5d5ac78728050c75 Mon Sep 17 00:00:00 2001 From: ktseng37 Date: Mon, 9 Sep 2024 15:33:58 -0700 Subject: [PATCH 2/2] fix function name --- pandas/core/groupby/groupby.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index ca05a77d814c1..38dad446b4c39 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -201,12 +201,12 @@ class providing the base-class of operations. See Also -------- -Series.min : Return the min of the group values. -DataFrame.min : Return the min of the group values. -Series.max : Return the max of the group values. -DataFrame.max : Return the max of the group values. -Series.sum : Return the sum of the group values. -DataFrame.sum : Return the sum of the group values. +SeriesGroupBy.min : Return the min of the group values. +DataFrameGroupBy.min : Return the min of the group values. +SeriesGroupBy.max : Return the max of the group values. +DataFrameGroupBy.max : Return the max of the group values. +SeriesGroupBy.sum : Return the sum of the group values. +DataFrameGroupBy.sum : Return the sum of the group values. Examples --------