@@ -459,9 +459,9 @@ def f(self):
459
459
460
460
461
461
@contextmanager
462
- def _group_selection_context (groupby : "_GroupBy" ):
462
+ def group_selection_context (groupby : "_GroupBy" ):
463
463
"""
464
- Set / reset the _group_selection_context .
464
+ Set / reset the group_selection_context .
465
465
"""
466
466
groupby ._set_group_selection ()
467
467
try :
@@ -737,7 +737,7 @@ def pipe(self, func, *args, **kwargs):
737
737
def _make_wrapper (self , name : str ) -> Callable :
738
738
assert name in self ._apply_allowlist
739
739
740
- with _group_selection_context (self ):
740
+ with group_selection_context (self ):
741
741
# need to setup the selection
742
742
# as are not passed directly but in the grouper
743
743
f = getattr (self ._obj_with_exclusions , name )
@@ -868,7 +868,7 @@ def f(g):
868
868
# fails on *some* columns, e.g. a numeric operation
869
869
# on a string grouper column
870
870
871
- with _group_selection_context (self ):
871
+ with group_selection_context (self ):
872
872
return self ._python_apply_general (f , self ._selected_obj )
873
873
874
874
return result
@@ -994,7 +994,7 @@ def _agg_general(
994
994
alias : str ,
995
995
npfunc : Callable ,
996
996
):
997
- with _group_selection_context (self ):
997
+ with group_selection_context (self ):
998
998
# try a cython aggregation if we can
999
999
try :
1000
1000
return self ._cython_agg_general (
@@ -1499,7 +1499,7 @@ def var(self, ddof: int = 1):
1499
1499
)
1500
1500
else :
1501
1501
func = lambda x : x .var (ddof = ddof )
1502
- with _group_selection_context (self ):
1502
+ with group_selection_context (self ):
1503
1503
return self ._python_agg_general (func )
1504
1504
1505
1505
@Substitution (name = "groupby" )
@@ -1658,7 +1658,7 @@ def ohlc(self) -> DataFrame:
1658
1658
1659
1659
@doc (DataFrame .describe )
1660
1660
def describe (self , ** kwargs ):
1661
- with _group_selection_context (self ):
1661
+ with group_selection_context (self ):
1662
1662
result = self .apply (lambda x : x .describe (** kwargs ))
1663
1663
if self .axis == 1 :
1664
1664
return result .T
@@ -1963,7 +1963,7 @@ def nth(self, n: Union[int, List[int]], dropna: Optional[str] = None) -> DataFra
1963
1963
nth_values = list (set (n ))
1964
1964
1965
1965
nth_array = np .array (nth_values , dtype = np .intp )
1966
- with _group_selection_context (self ):
1966
+ with group_selection_context (self ):
1967
1967
1968
1968
mask_left = np .in1d (self ._cumcount_array (), nth_array )
1969
1969
mask_right = np .in1d (
@@ -2226,7 +2226,7 @@ def ngroup(self, ascending: bool = True):
2226
2226
5 0
2227
2227
dtype: int64
2228
2228
"""
2229
- with _group_selection_context (self ):
2229
+ with group_selection_context (self ):
2230
2230
index = self ._selected_obj .index
2231
2231
result = self ._obj_1d_constructor (self .grouper .group_info [0 ], index )
2232
2232
if not ascending :
@@ -2287,7 +2287,7 @@ def cumcount(self, ascending: bool = True):
2287
2287
5 0
2288
2288
dtype: int64
2289
2289
"""
2290
- with _group_selection_context (self ):
2290
+ with group_selection_context (self ):
2291
2291
index = self ._selected_obj .index
2292
2292
cumcounts = self ._cumcount_array (ascending = ascending )
2293
2293
return self ._obj_1d_constructor (cumcounts , index )
0 commit comments