-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
PERF: groupby.quantile #43469
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
PERF: groupby.quantile #43469
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.
looks good!
cc @mzeitlin11
@@ -770,25 +770,25 @@ def group_ohlc(floating[:, ::1] out, | |||
|
|||
@cython.boundscheck(False) | |||
@cython.wraparound(False) | |||
def group_quantile(ndarray[float64_t] out, | |||
def group_quantile(ndarray[float64_t, ndim=2] out, |
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.
i think we name these _2d (or similar), thinking of rank of these are 2d based?
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.
not in this file
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.
kk, prob want to make a pass over the cython code to unify the names (e.g. append 1d or 2d) where appropriate
res_mgr = mgr.grouped_reduce(blk_func, ignore_failures=True) | ||
if len(res_mgr.items) != len(mgr.items): | ||
warnings.warn( | ||
"Dropping invalid columns in " |
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.
tests hit this?
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.
yep
) | ||
|
||
def blk_func(values: ArrayLike) -> ArrayLike: | ||
mask = isna(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.
0-dim dont' enter here right?
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.
correct
def _insert_quantile_level(idx: Index, qs: npt.NDArray[np.float64]) -> MultiIndex: | ||
""" | ||
Insert the sequence 'qs' of quantiles as the inner-most level of a MultiIndex. | ||
|
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 Paramters / Returns
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.
will do
prob worth a whatsnew note as large change in perf |
whatsnew added + green |
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! Might make a followup with couple things I noticed while reading through (but not expressly related to the pr, so no reason to block merging)
Nearly 10x