@@ -3809,24 +3809,31 @@ def rolling(
3809
3809
)
3810
3810
3811
3811
@final
3812
- def expanding (self , * args , ** kwargs ) -> ExpandingGroupby :
3812
+ def expanding (
3813
+ self ,
3814
+ min_periods : int = 1 ,
3815
+ method : str = "single" ,
3816
+ ) -> ExpandingGroupby :
3813
3817
"""
3814
3818
Return an expanding grouper, providing expanding functionality per group.
3815
3819
3816
- Arguments are the same as `:meth:DataFrame.rolling` except that ``step`` cannot
3817
- be specified.
3818
-
3819
3820
Parameters
3820
3821
----------
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.
3825
3832
3826
3833
Returns
3827
3834
-------
3828
3835
pandas.api.typing.ExpandingGroupby
3829
- An object that supports expanding transformations over each group.
3836
+ An object that supports expanding transformations over each group
3830
3837
3831
3838
See Also
3832
3839
--------
@@ -3844,7 +3851,7 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
3844
3851
... }
3845
3852
... )
3846
3853
>>> df
3847
- Class Value
3854
+ Class Value
3848
3855
0 A 10
3849
3856
1 A 20
3850
3857
2 A 30
@@ -3853,7 +3860,7 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
3853
3860
5 B 60
3854
3861
3855
3862
>>> df.groupby("Class").expanding().mean()
3856
- Value
3863
+ Value
3857
3864
Class
3858
3865
A 0 10.0
3859
3866
1 15.0
@@ -3866,9 +3873,9 @@ def expanding(self, *args, **kwargs) -> ExpandingGroupby:
3866
3873
3867
3874
return ExpandingGroupby (
3868
3875
self ._selected_obj ,
3869
- * args ,
3876
+ min_periods = min_periods ,
3877
+ method = method ,
3870
3878
_grouper = self ._grouper ,
3871
- ** kwargs ,
3872
3879
)
3873
3880
3874
3881
@final
0 commit comments