@@ -140,9 +140,16 @@ def get_iterator(
140
140
splitter = self ._get_splitter (data , axis = axis )
141
141
keys = self ._get_group_keys ()
142
142
for key , (i , group ) in zip (keys , splitter ):
143
- yield key , group
143
+ yield key , group . __finalize__ ( data , method = "groupby" )
144
144
145
145
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
+ """
146
153
comp_ids , _ , ngroups = self .group_info
147
154
return get_splitter (data , comp_ids , ngroups , axis = axis )
148
155
@@ -918,7 +925,8 @@ class SeriesSplitter(DataSplitter):
918
925
def _chop (self , sdata : Series , slice_obj : slice ) -> Series :
919
926
# fastpath equivalent to `sdata.iloc[slice_obj]`
920
927
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 )
922
930
923
931
924
932
class FrameSplitter (DataSplitter ):
@@ -934,7 +942,8 @@ def _chop(self, sdata: DataFrame, slice_obj: slice) -> DataFrame:
934
942
# else:
935
943
# return sdata.iloc[:, slice_obj]
936
944
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 )
938
947
939
948
940
949
def get_splitter (
0 commit comments