@@ -140,9 +140,16 @@ def get_iterator(
140140 splitter = self ._get_splitter (data , axis = axis )
141141 keys = self ._get_group_keys ()
142142 for key , (i , group ) in zip (keys , splitter ):
143- yield key , group
143+ yield key , group . __finalize__ ( data , method = "groupby" )
144144
145145 def _get_splitter (self , data : FrameOrSeries , axis : int = 0 ) -> "DataSplitter" :
146+ """
147+ Returns
148+ -------
149+ Generator yielding subsetted objects
150+
151+ __finalize__ has not been called for the the subsetted objects returned.
152+ """
146153 comp_ids , _ , ngroups = self .group_info
147154 return get_splitter (data , comp_ids , ngroups , axis = axis )
148155
@@ -918,7 +925,8 @@ class SeriesSplitter(DataSplitter):
918925 def _chop (self , sdata : Series , slice_obj : slice ) -> Series :
919926 # fastpath equivalent to `sdata.iloc[slice_obj]`
920927 mgr = sdata ._mgr .get_slice (slice_obj )
921- return type (sdata )(mgr , name = sdata .name , fastpath = True )
928+ # __finalize__ not called here, must be applied by caller if applicable
929+ return sdata ._constructor (mgr , name = sdata .name , fastpath = True )
922930
923931
924932class FrameSplitter (DataSplitter ):
@@ -934,7 +942,8 @@ def _chop(self, sdata: DataFrame, slice_obj: slice) -> DataFrame:
934942 # else:
935943 # return sdata.iloc[:, slice_obj]
936944 mgr = sdata ._mgr .get_slice (slice_obj , axis = 1 - self .axis )
937- return type (sdata )(mgr )
945+ # __finalize__ not called here, must be applied by caller if applicable
946+ return sdata ._constructor (mgr )
938947
939948
940949def get_splitter (
0 commit comments