-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Add engine keyword to expanding.apply to utilize Numba #30937
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
ENH: Add engine keyword to expanding.apply to utilize Numba #30937
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Do we have any benchmarks for this?
raw=False, | ||
engine="cython", | ||
engine_kwargs=None, | ||
args=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this totally equivalent? I get the impression previously should have been *args and **kwargs so a little strange as is, but I don't think converting to None
is totally the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously the docs described rolling/expanding.apply
being able to take *args, **kwargs: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.window.Expanding.apply.html
But in actuality, the arguments were args=(), kwargs={}
: https://github.com/pandas-dev/pandas/blob/0.25.x/pandas/core/window.py#L2128
Since the docs were incorrect, and the prior arguments has a mutable default argument, I changed rolling.apply
to be args=None, kwargs=None
(later converting to args=(), kwargs={}
internally if still None
), and I am doing the same here for expanding.apply
.
So slightly changing the behavior, but taking advantage of the fact the docs were incorrect in the first place.
pandas/core/window/expanding.py
Outdated
func, | ||
raw=False, | ||
engine="cython", | ||
engine_kwargs=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add annotation for this? I assume Dict[str, Any]
unless can further subset the provided values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
actually ok for 1.0.0; can you add this issues / PR number to the whatsnew note that already existis for rolling.apply |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff