Implement min_count for groupby reductions#22372
Open
galipremsagar wants to merge 1 commit intorapidsai:pandas3from
Open
Implement min_count for groupby reductions#22372galipremsagar wants to merge 1 commit intorapidsai:pandas3from
galipremsagar wants to merge 1 commit intorapidsai:pandas3from
Conversation
``GroupBy._reduce`` previously raised ``NotImplementedError`` when
``min_count != 0``, forcing cudf.pandas to fall back to the slow path.
Now run the requested aggregation, then mask result rows whose
per-group non-null count is below ``min_count`` (computed via
``self.agg("count")``). Supports both ``Series`` and ``DataFrame``
results.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
/okay to test 5f3e8ac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Split out from #22289.
GroupBy._reducepreviously raisedNotImplementedErrorwhenevermin_count != 0, forcingcudf.pandasto fall back to the slow path forgroupby.sum(min_count=...)and similar calls.Implementation (
python/cudf/cudf/core/groupby/groupby.py)Run the requested aggregation, then mask result rows whose per-group non-null count (computed via
self.agg(\"count\")) is belowmin_count. Supports bothSeriesandDataFrameresults.Tests
python/cudf/cudf/tests/groupby/test_reductions.py:test_groupby_reduce_min_countoversum,min,max,first,lastformin_countvalues 0, 1, 2, 3, 5.test_groupby_series_reduce_min_countforSeries.groupbypaths.Relationship to #22289
One of the four split PRs requested in the review on #22289. No conftest removals because the existing pandas-tests entries that fail with
min_counterrors also need the other split PRs (string sum, bool any/all, grouping-key exclusion) before they can be unmarked.