Skip to content

Commit dd47e19

Browse files
committed
updated expanding args
1 parent f8d5a16 commit dd47e19

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

pandas/core/groupby/groupby.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,24 +3809,31 @@ def rolling(
38093809
)
38103810

38113811
@final
3812-
def expanding(self, *args, **kwargs) -> ExpandingGroupby:
3812+
def expanding(
3813+
self,
3814+
min_periods: int = 1,
3815+
method: str = "single",
3816+
) -> ExpandingGroupby:
38133817
"""
38143818
Return an expanding grouper, providing expanding functionality per group.
38153819
3816-
Arguments are the same as `:meth:DataFrame.rolling` except that ``step`` cannot
3817-
be specified.
3818-
38193820
Parameters
38203821
----------
3821-
*args : tuple
3822-
Positional arguments passed to the expanding window constructor.
3823-
**kwargs : dict
3824-
Keyword arguments passed to the expanding window constructor.
3822+
min_periods : int, default 1
3823+
Minimum number of observations in window required to have a value;
3824+
otherwise, result is ``np.nan``.
3825+
3826+
method : str {'single', 'table'}, default 'single'
3827+
Execute the expanding operation per single column or row (``'single'``)
3828+
or over the entire object (``'table'``).
3829+
3830+
This argument is only implemented when specifying ``engine='numba'``
3831+
in the method call.
38253832
38263833
Returns
38273834
-------
38283835
pandas.api.typing.ExpandingGroupby
3829-
An object that supports expanding transformations over each group.
3836+
An object that supports expanding transformations over each group
38303837
38313838
See Also
38323839
--------
@@ -3844,7 +3851,7 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
38443851
... }
38453852
... )
38463853
>>> df
3847-
Class Value
3854+
Class Value
38483855
0 A 10
38493856
1 A 20
38503857
2 A 30
@@ -3853,7 +3860,7 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
38533860
5 B 60
38543861
38553862
>>> df.groupby("Class").expanding().mean()
3856-
Value
3863+
Value
38573864
Class
38583865
A 0 10.0
38593866
1 15.0
@@ -3866,9 +3873,9 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
38663873

38673874
return ExpandingGroupby(
38683875
self._selected_obj,
3869-
*args,
3876+
min_periods=min_periods,
3877+
method=method,
38703878
_grouper=self._grouper,
3871-
**kwargs,
38723879
)
38733880

38743881
@final

0 commit comments

Comments
 (0)