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