@@ -263,7 +263,8 @@ def apply_broadcast(self, target: "DataFrame") -> "DataFrame":
263263
264264 def apply_standard (self ):
265265
266- partial_result = None # partial result that may be returned from reduction.
266+ # partial result that may be returned from reduction
267+ partial_result = None
267268
268269 # try to reduce first (by default)
269270 # this only matters if the reduction in values is of different dtype
@@ -305,12 +306,12 @@ def apply_standard(self):
305306 else :
306307 if reduction_success :
307308 return self .obj ._constructor_sliced (result , index = labels )
308- else :
309- # no exceptions - however reduction was unsuccessful,
310- # use the computed function result for first element
311- partial_result = result [0 ]
312- if isinstance (partial_result , ABCSeries ):
313- partial_result = partial_result .infer_objects ()
309+
310+ # no exceptions - however reduction was unsuccessful,
311+ # use the computed function result for first element
312+ partial_result = result [0 ]
313+ if isinstance (partial_result , ABCSeries ):
314+ partial_result = partial_result .infer_objects ()
314315
315316 # compute the result using the series generator,
316317 # use the result computed while trying to reduce if available.
@@ -323,7 +324,6 @@ def apply_series_generator(self, partial_result=None) -> Tuple[ResType, "Index"]
323324 series_gen = self .series_generator
324325 res_index = self .result_index
325326
326- keys = []
327327 results = {}
328328
329329 # If a partial result was already computed,
@@ -332,7 +332,6 @@ def apply_series_generator(self, partial_result=None) -> Tuple[ResType, "Index"]
332332 if partial_result is not None :
333333 i , v = next (series_gen_enumeration )
334334 results [i ] = partial_result
335- keys .append (v .name )
336335
337336 if self .ignore_failures :
338337 successes = []
@@ -342,7 +341,6 @@ def apply_series_generator(self, partial_result=None) -> Tuple[ResType, "Index"]
342341 except Exception :
343342 pass
344343 else :
345- keys .append (v .name )
346344 successes .append (i )
347345
348346 # so will work with MultiIndex
@@ -353,7 +351,6 @@ def apply_series_generator(self, partial_result=None) -> Tuple[ResType, "Index"]
353351 for i , v in series_gen_enumeration :
354352
355353 results [i ] = self .f (v )
356- keys .append (v .name )
357354
358355 return results , res_index
359356
0 commit comments