@@ -131,9 +131,16 @@ def get_iterator(self, data: FrameOrSeries, axis: int = 0):
131
131
splitter = self ._get_splitter (data , axis = axis )
132
132
keys = self ._get_group_keys ()
133
133
for key , (i , group ) in zip (keys , splitter ):
134
- yield key , group
134
+ yield key , group . __finalize__ ( data , method = "groupby" )
135
135
136
136
def _get_splitter (self , data : FrameOrSeries , axis : int = 0 ) -> "DataSplitter" :
137
+ """
138
+ Returns
139
+ -------
140
+ Generator yielding subsetted objects
141
+
142
+ __finalize__ has not been called for the the subsetted objects returned.
143
+ """
137
144
comp_ids , _ , ngroups = self .group_info
138
145
return get_splitter (data , comp_ids , ngroups , axis = axis )
139
146
@@ -955,7 +962,8 @@ class SeriesSplitter(DataSplitter):
955
962
def _chop (self , sdata : Series , slice_obj : slice ) -> Series :
956
963
# fastpath equivalent to `sdata.iloc[slice_obj]`
957
964
mgr = sdata ._mgr .get_slice (slice_obj )
958
- return type (sdata )(mgr , name = sdata .name , fastpath = True )
965
+ # __finalize__ not called here, must be applied by caller if applicable
966
+ return sdata ._constructor (mgr , name = sdata .name , fastpath = True )
959
967
960
968
961
969
class FrameSplitter (DataSplitter ):
@@ -971,7 +979,8 @@ def _chop(self, sdata: DataFrame, slice_obj: slice) -> DataFrame:
971
979
# else:
972
980
# return sdata.iloc[:, slice_obj]
973
981
mgr = sdata ._mgr .get_slice (slice_obj , axis = 1 - self .axis )
974
- return type (sdata )(mgr )
982
+ # __finalize__ not called here, must be applied by caller if applicable
983
+ return sdata ._constructor (mgr )
975
984
976
985
977
986
def get_splitter (
0 commit comments