@@ -165,14 +165,17 @@ def apply(self, f, data, axis=0):
165165 mutated = self .mutated
166166 splitter = self ._get_splitter (data , axis = axis )
167167 group_keys = self ._get_group_keys ()
168-
168+ status = 0
169+ result_values = []
169170 # oh boy
170171 f_name = com .get_callable_name (f )
171172 if (f_name not in base .plotting_methods and
172173 hasattr (splitter , 'fast_apply' ) and axis == 0 ):
173174 try :
174- values , mutated = splitter .fast_apply (f , group_keys )
175- return group_keys , values , mutated
175+ result = splitter .fast_apply (f , group_keys )
176+ result_values , mutated , status = result
177+ if status == 0 :
178+ return group_keys , result_values , mutated
176179 except reduction .InvalidApply :
177180 # we detect a mutation of some kind
178181 # so take slow path
@@ -181,9 +184,10 @@ def apply(self, f, data, axis=0):
181184 # raise this error to the caller
182185 pass
183186
184- result_values = []
185187 for key , (i , group ) in zip (group_keys , splitter ):
186188 object .__setattr__ (group , 'name' , key )
189+ if status > 0 and i == 0 :
190+ continue
187191
188192 # group might be modified
189193 group_axes = _get_axes (group )
@@ -854,10 +858,7 @@ def fast_apply(self, f, names):
854858 return [], True
855859
856860 sdata = self ._get_sorted_data ()
857- results , mutated = reduction .apply_frame_axis0 (sdata , f , names ,
858- starts , ends )
859-
860- return results , mutated
861+ return reduction .apply_frame_axis0 (sdata , f , names , starts , ends )
861862
862863 def _chop (self , sdata , slice_obj ):
863864 if self .axis == 0 :
0 commit comments