Skip to content

DOC: Fix PR01 errors in multiple files (#57438) #57504

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 8 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
15 changes: 0 additions & 15 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.DatetimeIndex.std\
pandas.ExcelFile\
pandas.ExcelFile.parse\
pandas.Grouper\
pandas.HDFStore.append\
pandas.HDFStore.put\
pandas.Index.get_indexer_for\
Expand Down Expand Up @@ -1538,21 +1537,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.api.types.is_float\
pandas.api.types.is_hashable\
pandas.api.types.is_integer\
pandas.core.groupby.DataFrameGroupBy.cummax\
pandas.core.groupby.DataFrameGroupBy.cummin\
pandas.core.groupby.DataFrameGroupBy.cumprod\
pandas.core.groupby.DataFrameGroupBy.cumsum\
pandas.core.groupby.DataFrameGroupBy.filter\
pandas.core.groupby.DataFrameGroupBy.pct_change\
pandas.core.groupby.DataFrameGroupBy.rolling\
pandas.core.groupby.SeriesGroupBy.cummax\
pandas.core.groupby.SeriesGroupBy.cummin\
pandas.core.groupby.SeriesGroupBy.cumprod\
pandas.core.groupby.SeriesGroupBy.cumsum\
pandas.core.groupby.SeriesGroupBy.filter\
pandas.core.groupby.SeriesGroupBy.nunique\
pandas.core.groupby.SeriesGroupBy.pct_change\
pandas.core.groupby.SeriesGroupBy.rolling\
pandas.core.resample.Resampler.max\
pandas.core.resample.Resampler.min\
pandas.core.resample.Resampler.quantile\
Expand Down
16 changes: 15 additions & 1 deletion pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,20 @@ def true_and_notna(x) -> bool:
filtered = self._apply_filter(indices, dropna)
return filtered

_nunique_extra_params = dedent(
"""
Parameters
----------
dropna : bool, default True
Don't include NaN in the counts.
"""
)

@doc(extra_params=_nunique_extra_params)
Copy link
Member

Choose a reason for hiding this comment

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

Connecting with my other comment, can you avoid using doc here?

def nunique(self, dropna: bool = True) -> Series | DataFrame:
"""
Return number of unique elements in the group.

{extra_params}
Returns
-------
Series
Expand Down Expand Up @@ -1942,6 +1952,10 @@ def filter(self, func, dropna: bool = True, *args, **kwargs) -> DataFrame:
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
-------
Expand Down
58 changes: 58 additions & 0 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -4672,6 +4672,14 @@ def cumprod(self, *args, **kwargs) -> NDFrameT:
"""
Cumulative product for each group.

Parameters
----------
*args : tuple
Positional arguments to be passed to `func`.
**kwargs : dict
Additional/specific keyword arguments to be passed to the function,
such as `numeric_only` and `skipna`.

Returns
-------
Series or DataFrame
Expand Down Expand Up @@ -4722,6 +4730,14 @@ def cumsum(self, *args, **kwargs) -> NDFrameT:
"""
Cumulative sum for each group.

Parameters
----------
*args : tuple
Positional arguments to be passed to `func`.
**kwargs : dict
Additional/specific keyword arguments to be passed to the function,
such as `numeric_only` and `skipna`.

Returns
-------
Series or DataFrame
Expand Down Expand Up @@ -4776,6 +4792,14 @@ def cummin(
"""
Cumulative min for each group.

Parameters
----------
numeric_only : bool, default False
Include only `float`, `int` or `boolean` data.
**kwargs : dict, optional
Additional keyword arguments to be passed to the function, such as `skipna`,
to control whether NA/null values are ignored.

Returns
-------
Series or DataFrame
Expand Down Expand Up @@ -4838,6 +4862,14 @@ def cummax(
"""
Cumulative max for each group.

Parameters
----------
numeric_only : bool, default False
Include only `float`, `int` or `boolean` data.
**kwargs : dict, optional
Additional keyword arguments to be passed to the function, such as `skipna`,
to control whether NA/null values are ignored.

Returns
-------
Series or DataFrame
Expand Down Expand Up @@ -5134,6 +5166,32 @@ def pct_change(
"""
Calculate pct_change of each value to previous entry in group.

Parameters
----------
periods : int, default 1
Periods to shift for calculating percentage change. Comparing with
a period of 1 means adjacent elements are compared, whereas a period
of 2 compares every other element.

fill_method : FillnaOptions or None, default None
Specifies how to handle missing values after the initial shift
operation necessary for percentage change calculation. Users are
encouraged to handle missing values manually in future versions.
Valid options are:
- A FillnaOptions value ('ffill', 'bfill') for forward or backward filling.
- None to avoid filling.
Note: Usage is discouraged due to impending deprecation.

limit : int or None, default None
The maximum number of consecutive NA values to fill, based on the chosen
`fill_method`. Address NaN values prior to using `pct_change` as this
parameter is nearing deprecation.

freq : str, pandas offset object, or None, default None
The frequency increment for time series data (e.g., 'M' for month-end).
If None, the frequency is inferred from the index. Relevant for time
series data only.

Returns
-------
Series or DataFrame
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class Grouper:

Parameters
----------
*args
Currently unused, reserved for future use.
**kwargs
Dictionary of the keyword arguments to pass to Grouper.
key : str, defaults to None
Groupby key, which selects the grouping column of the target.
level : name/number, defaults to None
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ def ohlc(self):
return self._downsample("ohlc")

@final
@doc(SeriesGroupBy.nunique)
@doc(SeriesGroupBy.nunique, extra_params="")
Copy link
Member

Choose a reason for hiding this comment

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

Can you give this a distinct docstring (e.g. copy-paste the SeriesGroupBy.nunique docstring here) and avoid using doc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Since they're now their own distinct docstrings, I separated the examples too (added see alsos to each other instead)

def nunique(self):
return self._downsample("nunique")

Expand Down