Skip to content

Commit

Permalink
Remove leftover partial-result code (#35397)
Browse files Browse the repository at this point in the history
  • Loading branch information
alonme committed Jul 24, 2020
1 parent 00ea10c commit 8f54d14
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions pandas/core/apply.py
Expand Up @@ -252,33 +252,20 @@ def apply_broadcast(self, target: "DataFrame") -> "DataFrame":
return result

def apply_standard(self):

# partial result that may be returned from reduction
partial_result = None

# compute the result using the series generator,
# use the result computed while trying to reduce if available.
results, res_index = self.apply_series_generator(partial_result)
results, res_index = self.apply_series_generator()

# wrap results
return self.wrap_results(results, res_index)

def apply_series_generator(self, partial_result=None) -> Tuple[ResType, "Index"]:
def apply_series_generator(self) -> Tuple[ResType, "Index"]:
series_gen = self.series_generator
res_index = self.result_index

results = {}

# If a partial result was already computed,
# use it instead of running on the first element again
series_gen_enumeration = enumerate(series_gen)
if partial_result is not None:
i, v = next(series_gen_enumeration)
results[i] = partial_result

if self.ignore_failures:
successes = []
for i, v in series_gen_enumeration:
for i, v in enumerate(series_gen):
try:
results[i] = self.f(v)
except Exception:
Expand All @@ -292,7 +279,7 @@ def apply_series_generator(self, partial_result=None) -> Tuple[ResType, "Index"]

else:
with option_context("mode.chained_assignment", None):
for i, v in series_gen_enumeration:
for i, v in enumerate(series_gen):
# ignore SettingWithCopy here in case the user mutates
results[i] = self.f(v)
if isinstance(results[i], ABCSeries):
Expand Down

0 comments on commit 8f54d14

Please sign in to comment.