Skip to content

Commit d9b56a1

Browse files
Fixed Series.apply performance regression (#35166)
1 parent 02a6acf commit d9b56a1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pandas/core/apply.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,14 @@ def apply_series_generator(self, partial_result=None) -> Tuple[ResType, "Index"]
291291
res_index = res_index.take(successes)
292292

293293
else:
294-
for i, v in series_gen_enumeration:
295-
296-
with option_context("mode.chained_assignment", None):
294+
with option_context("mode.chained_assignment", None):
295+
for i, v in series_gen_enumeration:
297296
# ignore SettingWithCopy here in case the user mutates
298297
results[i] = self.f(v)
299-
300-
if isinstance(results[i], ABCSeries):
301-
# If we have a view on v, we need to make a copy because
302-
# series_generator will swap out the underlying data
303-
results[i] = results[i].copy(deep=False)
298+
if isinstance(results[i], ABCSeries):
299+
# If we have a view on v, we need to make a copy because
300+
# series_generator will swap out the underlying data
301+
results[i] = results[i].copy(deep=False)
304302

305303
return results, res_index
306304

0 commit comments

Comments
 (0)