Skip to content

Commit d0aa9ad

Browse files
jordan-d-murphypmhatre1
authored andcommitted
DOC: fix PR02 errors in docstrings - groupby.idxmax (pandas-dev#57145)
1 parent 4c9a457 commit d0aa9ad

File tree

2 files changed

+94
-4
lines changed

2 files changed

+94
-4
lines changed

ci/code_checks.sh

-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
173173
pandas.core.groupby.DataFrameGroupBy.transform\
174174
pandas.core.groupby.DataFrameGroupBy.nth\
175175
pandas.core.groupby.DataFrameGroupBy.rolling\
176-
pandas.core.groupby.SeriesGroupBy.idxmax\
177-
pandas.core.groupby.SeriesGroupBy.idxmin\
178176
pandas.core.groupby.SeriesGroupBy.nth\
179177
pandas.core.groupby.SeriesGroupBy.rolling\
180178
pandas.core.groupby.DataFrameGroupBy.hist\

pandas/core/groupby/generic.py

+94-2
Original file line numberDiff line numberDiff line change
@@ -1033,12 +1033,104 @@ def nsmallest(
10331033
result = self._python_apply_general(f, data, not_indexed_same=True)
10341034
return result
10351035

1036-
@doc(Series.idxmin.__doc__)
10371036
def idxmin(self, skipna: bool = True) -> Series:
1037+
"""
1038+
Return the row label of the minimum value.
1039+
1040+
If multiple values equal the minimum, the first row label with that
1041+
value is returned.
1042+
1043+
Parameters
1044+
----------
1045+
skipna : bool, default True
1046+
Exclude NA/null values. If the entire Series is NA, the result
1047+
will be NA.
1048+
1049+
Returns
1050+
-------
1051+
Index
1052+
Label of the minimum value.
1053+
1054+
Raises
1055+
------
1056+
ValueError
1057+
If the Series is empty.
1058+
1059+
See Also
1060+
--------
1061+
numpy.argmin : Return indices of the minimum values
1062+
along the given axis.
1063+
DataFrame.idxmin : Return index of first occurrence of minimum
1064+
over requested axis.
1065+
Series.idxmax : Return index *label* of the first occurrence
1066+
of maximum of values.
1067+
1068+
Examples
1069+
--------
1070+
>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
1071+
... ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
1072+
>>> ser
1073+
2023-01-01 1
1074+
2023-01-15 2
1075+
2023-02-01 3
1076+
2023-02-15 4
1077+
dtype: int64
1078+
1079+
>>> ser.groupby(['a', 'a', 'b', 'b']).idxmin()
1080+
a 2023-01-01
1081+
b 2023-02-01
1082+
dtype: datetime64[ns]
1083+
"""
10381084
return self._idxmax_idxmin("idxmin", skipna=skipna)
10391085

1040-
@doc(Series.idxmax.__doc__)
10411086
def idxmax(self, skipna: bool = True) -> Series:
1087+
"""
1088+
Return the row label of the maximum value.
1089+
1090+
If multiple values equal the maximum, the first row label with that
1091+
value is returned.
1092+
1093+
Parameters
1094+
----------
1095+
skipna : bool, default True
1096+
Exclude NA/null values. If the entire Series is NA, the result
1097+
will be NA.
1098+
1099+
Returns
1100+
-------
1101+
Index
1102+
Label of the maximum value.
1103+
1104+
Raises
1105+
------
1106+
ValueError
1107+
If the Series is empty.
1108+
1109+
See Also
1110+
--------
1111+
numpy.argmax : Return indices of the maximum values
1112+
along the given axis.
1113+
DataFrame.idxmax : Return index of first occurrence of maximum
1114+
over requested axis.
1115+
Series.idxmin : Return index *label* of the first occurrence
1116+
of minimum of values.
1117+
1118+
Examples
1119+
--------
1120+
>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
1121+
... ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
1122+
>>> ser
1123+
2023-01-01 1
1124+
2023-01-15 2
1125+
2023-02-01 3
1126+
2023-02-15 4
1127+
dtype: int64
1128+
1129+
>>> ser.groupby(['a', 'a', 'b', 'b']).idxmax()
1130+
a 2023-01-15
1131+
b 2023-02-15
1132+
dtype: datetime64[ns]
1133+
"""
10421134
return self._idxmax_idxmin("idxmax", skipna=skipna)
10431135

10441136
@doc(Series.corr.__doc__)

0 commit comments

Comments
 (0)