Skip to content

Conversation

TomAugspurger
Copy link
Contributor

Set the option once, rather than in the loop.

Closes #35047

import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(1000, 3), columns=list("ABC"))
%timeit df.apply(lambda x: x["A"] + x["B"], axis=1)
# 1.0.4
22.5 ms ± 4.73 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

# PR
10.4 ms ± 714 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

Set the option once, rather than in the loop.

Closes pandas-dev#35047
@TomAugspurger TomAugspurger added this to the 1.1 milestone Jul 7, 2020
@TomAugspurger TomAugspurger added Apply Apply, Aggregate, Transform, Map Performance Memory or execution speed performance labels Jul 7, 2020
@jbrockmendel
Copy link
Member

Nice!

@jreback jreback merged commit d9b56a1 into pandas-dev:master Jul 8, 2020
@jreback
Copy link
Contributor

jreback commented Jul 8, 2020

thanks @TomAugspurger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance regression in frame_methods.Apply.time_apply_ref_by_name
4 participants