@@ -888,9 +888,8 @@ def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs)
888
888
relabeling , func , columns , order , _ = reconstruct_func (func , ** kwargs )
889
889
func = maybe_mangle_lambdas (func )
890
890
891
- with group_selection_context (self ):
892
- op = GroupByApply (self , func , args , kwargs )
893
- result = op .agg ()
891
+ op = GroupByApply (self , func , args , kwargs )
892
+ result = op .agg ()
894
893
if not is_dict_like (func ) and result is not None :
895
894
return result
896
895
elif relabeling and result is not None :
@@ -937,8 +936,6 @@ def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs)
937
936
gba = GroupByApply (self , [func ], args = (), kwargs = {})
938
937
try :
939
938
result = gba .agg ()
940
- if get_option ("new_udf_methods" ) and result is None :
941
- result = self ._aggregate_frame (func )
942
939
943
940
except ValueError as err :
944
941
if "no results" not in str (err ):
@@ -960,8 +957,7 @@ def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs)
960
957
)
961
958
# select everything except for the last level, which is the
962
959
# one containing the name of the function(s), see GH#32040
963
- if not get_option ("new_udf_methods" ):
964
- result .columns = result .columns .droplevel (- 1 )
960
+ result .columns = result .columns .droplevel (- 1 )
965
961
966
962
if not self .as_index :
967
963
self ._insert_inaxis_grouper_inplace (result )
0 commit comments