Skip to content

Commit fcc44d5

Browse files
committed
Fixed Series.apply performance regression
Set the option once, rather than in the loop. Closes pandas-dev#35047
1 parent 7453810 commit fcc44d5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pandas/core/apply.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,8 @@ 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)
299298

0 commit comments

Comments
 (0)