Skip to content

PERF: Rolling._apply #43171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 25, 2021
Merged

PERF: Rolling._apply #43171

merged 7 commits into from
Aug 25, 2021

Conversation

jbrockmendel
Copy link
Member

from asv_bench.benchmarks.rolling import *

self = Engine()
self.setup("DataFrame", "float", sum, "cython", "sum")
self.time_rolling_methods("DataFrame", "float", sum, "cython", "sum")

%timeit self.time_rolling_methods("DataFrame", "float", sum, "cython", "sum")
150 µs ± 889 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)  # <- PR
224 µs ± 3.18 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)  # <- master

cc @mroeschke

@mroeschke
Copy link
Member

There's an _apply_series which looks like a 1D case of _apply_blockwise; can that be refactored into _apply_blockwise?

_apply_blockwise maybe should be renamed to _apply_columnwise

@jbrockmendel
Copy link
Member Author

Updated timings:

from asv_bench.benchmarks.rolling import *

self = Engine()
self.setup("DataFrame", "float", sum, "cython", "sum")
self.time_rolling_methods("DataFrame", "float", sum, "cython", "sum")

%timeit self.time_rolling_methods("DataFrame", "float", sum, "cython", "sum")
209 µs ± 8.64 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)  # <- master
147 µs ± 3.32 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)  # <- PR, consolidate=True
133 µs ± 1.95 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)  # <- PR, consolidate=False

I'm OK with consolidating at that cost.

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Does this deserve a whatsnew note?

@jbrockmendel
Copy link
Member Author

Does this deserve a whatsnew note?

either way i guess, i can add something in the next "assorted follow-ups" PR

@mroeschke mroeschke merged commit e218f05 into pandas-dev:master Aug 25, 2021
@mroeschke
Copy link
Member

Sure that sounds good. Thanks @jbrockmendel

@mroeschke mroeschke added this to the 1.4 milestone Aug 25, 2021
@mroeschke mroeschke added Performance Memory or execution speed performance Window rolling, ewma, expanding labels Aug 25, 2021
@jbrockmendel jbrockmendel deleted the perf-rolling branch August 25, 2021 02:12
feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
* PERF: Rolling._apply

* consolidate

* remove consolidate arg

* fix construction

* fix warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PERF: Rolling._apply iterates over blocks _and_ columns
2 participants