@@ -705,17 +705,14 @@ def get_iterator(
705
705
"""
706
706
splitter = self ._get_splitter (data , axis = axis )
707
707
keys = self .group_keys_seq
708
- for key , group in zip (keys , splitter ):
709
- yield key , group .__finalize__ (data , method = "groupby" )
708
+ yield from zip (keys , splitter )
710
709
711
710
@final
712
711
def _get_splitter (self , data : NDFrame , axis : int = 0 ) -> DataSplitter :
713
712
"""
714
713
Returns
715
714
-------
716
715
Generator yielding subsetted objects
717
-
718
- __finalize__ has not been called for the subsetted objects returned.
719
716
"""
720
717
ids , _ , ngroups = self .group_info
721
718
return get_splitter (data , ids , ngroups , axis = axis )
@@ -753,7 +750,6 @@ def apply(
753
750
zipped = zip (group_keys , splitter )
754
751
755
752
for key , group in zipped :
756
- group = group .__finalize__ (data , method = "groupby" )
757
753
object .__setattr__ (group , "name" , key )
758
754
759
755
# group might be modified
@@ -1001,7 +997,6 @@ def _aggregate_series_pure_python(
1001
997
splitter = get_splitter (obj , ids , ngroups , axis = 0 )
1002
998
1003
999
for i , group in enumerate (splitter ):
1004
- group = group .__finalize__ (obj , method = "groupby" )
1005
1000
res = func (group )
1006
1001
res = libreduction .extract_result (res )
1007
1002
@@ -1244,8 +1239,9 @@ class SeriesSplitter(DataSplitter):
1244
1239
def _chop (self , sdata : Series , slice_obj : slice ) -> Series :
1245
1240
# fastpath equivalent to `sdata.iloc[slice_obj]`
1246
1241
mgr = sdata ._mgr .get_slice (slice_obj )
1247
- # __finalize__ not called here, must be applied by caller if applicable
1248
- return sdata ._constructor (mgr , name = sdata .name , fastpath = True )
1242
+ return sdata ._constructor (mgr , name = sdata .name , fastpath = True ).__finalize__ (
1243
+ sdata , method = "groupby"
1244
+ )
1249
1245
1250
1246
1251
1247
class FrameSplitter (DataSplitter ):
@@ -1256,8 +1252,7 @@ def _chop(self, sdata: DataFrame, slice_obj: slice) -> DataFrame:
1256
1252
# else:
1257
1253
# return sdata.iloc[:, slice_obj]
1258
1254
mgr = sdata ._mgr .get_slice (slice_obj , axis = 1 - self .axis )
1259
- # __finalize__ not called here, must be applied by caller if applicable
1260
- return sdata ._constructor (mgr )
1255
+ return sdata ._constructor (mgr ).__finalize__ (sdata , method = "groupby" )
1261
1256
1262
1257
1263
1258
def get_splitter (
0 commit comments