Skip to content

Commit b2ffbfe

Browse files
authored
* chore: update function definition * chore: added idxmax and idxmin tests * chore: remove numeric_only from series
1 parent 300adaf commit b2ffbfe

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

pandas-stubs/core/groupby/generic.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class SeriesGroupBy(GroupBy, Generic[S1]):
143143
legend: bool = ...,
144144
**kwargs,
145145
) -> AxesSubplot: ...
146+
def idxmax(self, axis: AxisType = ..., skipna: bool = ...) -> Series: ...
147+
def idxmin(self, axis: AxisType = ..., skipna: bool = ...) -> Series: ...
146148

147149
class _DataFrameGroupByScalar(DataFrameGroupBy):
148150
def __iter__(self) -> Iterator[tuple[Scalar, DataFrame]]: ...
@@ -273,10 +275,10 @@ class DataFrameGroupBy(GroupBy):
273275
) -> AxesSubplot | Sequence[AxesSubplot]: ...
274276
def idxmax(
275277
self, axis: AxisType = ..., skipna: bool = ..., numeric_only: bool = ...
276-
) -> Series: ...
278+
) -> DataFrame: ...
277279
def idxmin(
278280
self, axis: AxisType = ..., skipna: bool = ..., numeric_only: bool = ...
279-
) -> Series: ...
281+
) -> DataFrame: ...
280282
def last(self, **kwargs) -> DataFrame: ...
281283
def max(self, **kwargs) -> DataFrame: ...
282284
def mean(self, **kwargs) -> DataFrame: ...

tests/test_frame.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,8 @@ def test_types_groupby_methods() -> None:
877877
pd.Series,
878878
float,
879879
)
880+
check(assert_type(df.groupby("col1").idxmax(), pd.DataFrame), pd.DataFrame)
881+
check(assert_type(df.groupby("col1").idxmin(), pd.DataFrame), pd.DataFrame)
880882

881883

882884
def test_types_groupby_agg() -> None:

tests/test_series.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ def test_types_groupby_methods() -> None:
519519
check(assert_type(s.groupby(level=0).var(), "pd.Series[float]"), pd.Series, float)
520520
check(assert_type(s.groupby(level=0).tail(), "pd.Series[int]"), pd.Series, np.int_)
521521
check(assert_type(s.groupby(level=0).unique(), pd.Series), pd.Series)
522+
check(assert_type(s.groupby(level=0).idxmax(), pd.Series), pd.Series)
523+
check(assert_type(s.groupby(level=0).idxmin(), pd.Series), pd.Series)
522524

523525

524526
def test_types_groupby_agg() -> None:

0 commit comments

Comments
 (0)