@@ -165,14 +165,17 @@ def apply(self, f, data, axis=0):
165
165
mutated = self .mutated
166
166
splitter = self ._get_splitter (data , axis = axis )
167
167
group_keys = self ._get_group_keys ()
168
-
168
+ status = 0
169
+ result_values = []
169
170
# oh boy
170
171
f_name = com .get_callable_name (f )
171
172
if (f_name not in base .plotting_methods and
172
173
hasattr (splitter , 'fast_apply' ) and axis == 0 ):
173
174
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
176
179
except reduction .InvalidApply :
177
180
# we detect a mutation of some kind
178
181
# so take slow path
@@ -181,9 +184,10 @@ def apply(self, f, data, axis=0):
181
184
# raise this error to the caller
182
185
pass
183
186
184
- result_values = []
185
187
for key , (i , group ) in zip (group_keys , splitter ):
186
188
object .__setattr__ (group , 'name' , key )
189
+ if status > 0 and i == 0 :
190
+ continue
187
191
188
192
# group might be modified
189
193
group_axes = _get_axes (group )
@@ -854,10 +858,7 @@ def fast_apply(self, f, names):
854
858
return [], True
855
859
856
860
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 )
861
862
862
863
def _chop (self , sdata , slice_obj ):
863
864
if self .axis == 0 :
0 commit comments