Skip to content

Commit 0fce6b4

Browse files
authored
DOC: Updated groupby.expanding arguments (#61352)
* updated expanding args * fixed punctuation
1 parent 20d5b1c commit 0fce6b4

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

pandas/core/groupby/groupby.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -3810,19 +3810,26 @@ def rolling(
38103810
)
38113811

38123812
@final
3813-
def expanding(self, *args, **kwargs) -> ExpandingGroupby:
3813+
def expanding(
3814+
self,
3815+
min_periods: int = 1,
3816+
method: str = "single",
3817+
) -> ExpandingGroupby:
38143818
"""
38153819
Return an expanding grouper, providing expanding functionality per group.
38163820
3817-
Arguments are the same as `:meth:DataFrame.rolling` except that ``step`` cannot
3818-
be specified.
3819-
38203821
Parameters
38213822
----------
3822-
*args : tuple
3823-
Positional arguments passed to the expanding window constructor.
3824-
**kwargs : dict
3825-
Keyword arguments passed to the expanding window constructor.
3823+
min_periods : int, default 1
3824+
Minimum number of observations in window required to have a value;
3825+
otherwise, result is ``np.nan``.
3826+
3827+
method : str {'single', 'table'}, default 'single'
3828+
Execute the expanding operation per single column or row (``'single'``)
3829+
or over the entire object (``'table'``).
3830+
3831+
This argument is only implemented when specifying ``engine='numba'``
3832+
in the method call.
38263833
38273834
Returns
38283835
-------
@@ -3845,7 +3852,7 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
38453852
... }
38463853
... )
38473854
>>> df
3848-
Class Value
3855+
Class Value
38493856
0 A 10
38503857
1 A 20
38513858
2 A 30
@@ -3854,7 +3861,7 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
38543861
5 B 60
38553862
38563863
>>> df.groupby("Class").expanding().mean()
3857-
Value
3864+
Value
38583865
Class
38593866
A 0 10.0
38603867
1 15.0
@@ -3867,9 +3874,9 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
38673874

38683875
return ExpandingGroupby(
38693876
self._selected_obj,
3870-
*args,
3877+
min_periods=min_periods,
3878+
method=method,
38713879
_grouper=self._grouper,
3872-
**kwargs,
38733880
)
38743881

38753882
@final

0 commit comments

Comments
 (0)