Skip to content

Commit 70c412c

Browse files
authored
SeriesGroupBy.diff (#702)
1 parent 64c339b commit 70c412c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pandas-stubs/core/groupby/generic.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class SeriesGroupBy(GroupBy, Generic[S1, ByT]):
141141
def idxmax(self, axis: Axis = ..., skipna: bool = ...) -> Series: ...
142142
def idxmin(self, axis: Axis = ..., skipna: bool = ...) -> Series: ...
143143
def __iter__(self) -> Iterator[tuple[ByT, Series[S1]]]: ...
144+
def diff(self, periods: int = ..., axis: Axis = ...) -> Series: ...
144145

145146
class DataFrameGroupBy(GroupBy, Generic[ByT]):
146147
def any(self, skipna: bool = ...) -> DataFrame: ...

tests/test_series.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,3 +1980,9 @@ def test_to_json_mode() -> None:
19801980
check(assert_type(result4, str), str)
19811981
if TYPE_CHECKING_INVALID_USAGE:
19821982
result3 = s.to_json(orient="records", lines=False, mode="a") # type: ignore[call-overload] # pyright: ignore[reportGeneralTypeIssues]
1983+
1984+
1985+
def test_groupby_diff() -> None:
1986+
# GH 658
1987+
s = pd.Series([1, 2, 3, np.nan])
1988+
check(assert_type(s.groupby(level=0).diff(), pd.Series), pd.Series)

0 commit comments

Comments
 (0)