From d991fed08ce9190b167faaca08a521b40a433663 Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Tue, 16 Apr 2024 09:51:41 +0530 Subject: [PATCH 1/5] fixed PR02,SA01 in docstring for pandas.Grouper --- pandas/core/groupby/grouper.py | 44 ++++------------------------------ 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/pandas/core/groupby/grouper.py b/pandas/core/groupby/grouper.py index 124730e1b5ca9..9724553f77a02 100644 --- a/pandas/core/groupby/grouper.py +++ b/pandas/core/groupby/grouper.py @@ -71,45 +71,6 @@ class Grouper: 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 - The level for the target index. - freq : str / frequency object, defaults to None - This will groupby the specified frequency if the target selection - (via key or level) is a datetime-like object. For full specification - of available frequencies, please see :ref:`here`. - sort : bool, default to False - Whether to sort the resulting labels. - closed : {'left' or 'right'} - Closed end of interval. Only when `freq` parameter is passed. - label : {'left' or 'right'} - Interval boundary to use for labeling. - Only when `freq` parameter is passed. - convention : {'start', 'end', 'e', 's'} - If grouper is PeriodIndex and `freq` parameter is passed. - - origin : Timestamp or str, default 'start_day' - The timestamp on which to adjust the grouping. The timezone of origin must - match the timezone of the index. - If string, must be one of the following: - - - 'epoch': `origin` is 1970-01-01 - - 'start': `origin` is the first value of the timeseries - - 'start_day': `origin` is the first day at midnight of the timeseries - - - 'end': `origin` is the last value of the timeseries - - 'end_day': `origin` is the ceiling midnight of the last day - - .. versionadded:: 1.3.0 - - offset : Timedelta or str, default is None - An offset timedelta added to the origin. - - dropna : bool, default True - If True, and if group keys contain NA values, NA values together with - row/column will be dropped. If False, NA values will also be treated as - the key in groups. Returns ------- @@ -117,6 +78,11 @@ class Grouper: A TimeGrouper is returned if ``freq`` is not ``None``. Otherwise, a Grouper is returned. + See ALso + ---------- + GroupBy : For grouping and aggregating relational data. + GroupByPlot : Class implementing the .plot attribute for groupby objects. + Examples -------- ``df.groupby(pd.Grouper(key="Animal"))`` is equivalent to ``df.groupby('Animal')`` From 9e565132a73fcf365aed3435138ab25a05da8b9e Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Tue, 16 Apr 2024 09:52:39 +0530 Subject: [PATCH 2/5] removed method pandas.Grouper --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 66f6bfd7195f9..17e7e72796b8d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -153,7 +153,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.DatetimeTZDtype SA01" \ -i "pandas.DatetimeTZDtype.tz SA01" \ -i "pandas.DatetimeTZDtype.unit SA01" \ - -i "pandas.Grouper PR02,SA01" \ -i "pandas.HDFStore.append PR01,SA01" \ -i "pandas.HDFStore.get SA01" \ -i "pandas.HDFStore.groups SA01" \ From 748c752ec3de4f5fee488fe5d4a4219cc3d706f9 Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Tue, 16 Apr 2024 23:35:02 +0530 Subject: [PATCH 3/5] restored parameters for Grouper with an extra indentation --- pandas/core/groupby/grouper.py | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/pandas/core/groupby/grouper.py b/pandas/core/groupby/grouper.py index 9724553f77a02..dab3ba1918978 100644 --- a/pandas/core/groupby/grouper.py +++ b/pandas/core/groupby/grouper.py @@ -72,13 +72,53 @@ class Grouper: **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 + The level for the target index. + freq : str / frequency object, defaults to None + This will groupby the specified frequency if the target selection + (via key or level) is a datetime-like object. For full specification + of available frequencies, please see :ref:`here`. + sort : bool, default to False + Whether to sort the resulting labels. + closed : {'left' or 'right'} + Closed end of interval. Only when `freq` parameter is passed. + label : {'left' or 'right'} + Interval boundary to use for labeling. + Only when `freq` parameter is passed. + convention : {'start', 'end', 'e', 's'} + If grouper is PeriodIndex and `freq` parameter is passed. + + origin : Timestamp or str, default 'start_day' + The timestamp on which to adjust the grouping. The timezone of origin must + match the timezone of the index. + If string, must be one of the following: + + - 'epoch': `origin` is 1970-01-01 + - 'start': `origin` is the first value of the timeseries + - 'start_day': `origin` is the first day at midnight of the timeseries + + - 'end': `origin` is the last value of the timeseries + - 'end_day': `origin` is the ceiling midnight of the last day + + .. versionadded:: 1.3.0 + + offset : Timedelta or str, default is None + An offset timedelta added to the origin. + + dropna : bool, default True + If True, and if group keys contain NA values, NA values together with + row/column will be dropped. If False, NA values will also be treated as + the key in groups. + Returns ------- Grouper or pandas.api.typing.TimeGrouper A TimeGrouper is returned if ``freq`` is not ``None``. Otherwise, a Grouper is returned. - See ALso + See Also ---------- GroupBy : For grouping and aggregating relational data. GroupByPlot : Class implementing the .plot attribute for groupby objects. From a6e5c778f4b0a09a2959086dd379e073e6f648c5 Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Wed, 17 Apr 2024 09:14:04 +0530 Subject: [PATCH 4/5] restored parameters and fixed See Also section --- pandas/core/groupby/grouper.py | 83 +++++++++++++++++----------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/pandas/core/groupby/grouper.py b/pandas/core/groupby/grouper.py index dab3ba1918978..2d10bd5d00eb2 100644 --- a/pandas/core/groupby/grouper.py +++ b/pandas/core/groupby/grouper.py @@ -71,46 +71,45 @@ class Grouper: 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 + The level for the target index. + freq : str / frequency object, defaults to None + This will groupby the specified frequency if the target selection + (via key or level) is a datetime-like object. For full specification + of available frequencies, please see :ref:`here`. + sort : bool, default to False + Whether to sort the resulting labels. + closed : {'left' or 'right'} + Closed end of interval. Only when `freq` parameter is passed. + label : {'left' or 'right'} + Interval boundary to use for labeling. + Only when `freq` parameter is passed. + convention : {'start', 'end', 'e', 's'} + If grouper is PeriodIndex and `freq` parameter is passed. + + origin : Timestamp or str, default 'start_day' + The timestamp on which to adjust the grouping. The timezone of origin must + match the timezone of the index. + If string, must be one of the following: + + - 'epoch': `origin` is 1970-01-01 + - 'start': `origin` is the first value of the timeseries + - 'start_day': `origin` is the first day at midnight of the timeseries + + - 'end': `origin` is the last value of the timeseries + - 'end_day': `origin` is the ceiling midnight of the last day + + .. versionadded:: 1.3.0 + + offset : Timedelta or str, default is None + An offset timedelta added to the origin. - key : str, defaults to None - Groupby key, which selects the grouping column of the target. - level : name/number, defaults to None - The level for the target index. - freq : str / frequency object, defaults to None - This will groupby the specified frequency if the target selection - (via key or level) is a datetime-like object. For full specification - of available frequencies, please see :ref:`here`. - sort : bool, default to False - Whether to sort the resulting labels. - closed : {'left' or 'right'} - Closed end of interval. Only when `freq` parameter is passed. - label : {'left' or 'right'} - Interval boundary to use for labeling. - Only when `freq` parameter is passed. - convention : {'start', 'end', 'e', 's'} - If grouper is PeriodIndex and `freq` parameter is passed. - - origin : Timestamp or str, default 'start_day' - The timestamp on which to adjust the grouping. The timezone of origin must - match the timezone of the index. - If string, must be one of the following: - - - 'epoch': `origin` is 1970-01-01 - - 'start': `origin` is the first value of the timeseries - - 'start_day': `origin` is the first day at midnight of the timeseries - - - 'end': `origin` is the last value of the timeseries - - 'end_day': `origin` is the ceiling midnight of the last day - - .. versionadded:: 1.3.0 - - offset : Timedelta or str, default is None - An offset timedelta added to the origin. - - dropna : bool, default True - If True, and if group keys contain NA values, NA values together with - row/column will be dropped. If False, NA values will also be treated as - the key in groups. + dropna : bool, default True + If True, and if group keys contain NA values, NA values together with + row/column will be dropped. If False, NA values will also be treated as + the key in groups. Returns ------- @@ -119,9 +118,9 @@ class Grouper: is returned. See Also - ---------- - GroupBy : For grouping and aggregating relational data. - GroupByPlot : Class implementing the .plot attribute for groupby objects. + -------- + Series.groupby : Apply a function groupby to a Series. + DataFrame.groupby : Apply a function groupby. Examples -------- From 5764f9fabe5c1a482f583f9a9e54d038e00720e0 Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Wed, 17 Apr 2024 09:49:09 +0530 Subject: [PATCH 5/5] removed SA01 for pandas.Grouper --- ci/code_checks.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 17e7e72796b8d..782d20ac5b724 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -153,6 +153,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.DatetimeTZDtype SA01" \ -i "pandas.DatetimeTZDtype.tz SA01" \ -i "pandas.DatetimeTZDtype.unit SA01" \ + -i "pandas.Grouper PR02" \ -i "pandas.HDFStore.append PR01,SA01" \ -i "pandas.HDFStore.get SA01" \ -i "pandas.HDFStore.groups SA01" \