-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: groupby().rolling(freq) with monotonic dates within groups #46065
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.
lgtm, does the iteration in _validate_datetimelike_monotonic have a big performance impact?
There will be a slight performance impact during the validation (that can be a 1 time hit) that scales with the number of groups. Here's validating 3 vs 100 groups
|
…onic dates within groups
@mroeschke - It looks like the call to |
if self._on.hasnans: | ||
raise ValueError(f"{on} must not have any NaT values.") | ||
for group_indices in self._grouper.indices.values(): | ||
group_on = self._on.take(group_indices) |
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.
yeah this is materializing things
prob not a great idea
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.
self._on is already materialized in __init__
. Is that what is meant by materialized?
@mroeschke there was no hurry on this one |
…ps (pandas-dev#46065)" This reverts commit ad0f1bf.
Sorry I was too eager on the LGTM. #46078 reverts this PR. This validation is O(number of groups). Happy to have a suggestion regarding a more performant solution. |
This PR was reverted yet did fix a regression in 1.4.0. In the absence of further PRs submitted to fix the reported regression, I propose undoing the revert of this PR to include this in 1.4.2 as performance is secondary to correctness? this worked (for the sorted groups case) in 1.3.5 so maybe a fix that only resolves that scenario would be more performant? If we merge this and are subsequently able to improve performance, we could maybe also consider backporting the performance improvement. |
We're hitting this issue in ibis in a few of our tests cases and it would be great if the revert of this could be undone. |
I took another look, I'm not in love with the amount of compute done in For better performance, can we leverage Index? Adapting the example from #46065 (comment)
I get
Profiling this shows almost all the time spent checking the monotonicity. However
Results in True and I get |
Interestingly, I guess for a
Unfortunately we can't use
|
…s-dev#46065 (pandas-dev#46567) (cherry picked from commit d2aa44f)
…ps (pandas-dev#46065)" (pandas-dev#46078) This reverts commit ad0f1bf.
doc/source/whatsnew/v1.4.2.rst
file if fixing a bug or adding a new feature.