Repository navigation
Closes #5307: Replace _make_aggop with Explicit Aggregation Method Definitions - #5451
Merged
Merged
Conversation
ajpotts
force-pushed
the
5307_Replace_make_aggop
branch
from
March 2, 2026 21:27
b4787c7 to
5d9a8e7
Compare
… Method Definitions
ajpotts
force-pushed
the
5307_Replace_make_aggop
branch
from
March 2, 2026 22:06
5d9a8e7 to
ec1054d
Compare
jaketrookman
approved these changes
Mar 3, 2026
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.
Refactor GroupBy and Series Aggregation to Explicit Methods
Summary
This PR removes dynamic method generation for aggregation operations in:
DataFrameGroupByDiffAggregateSeriesand replaces them with explicitly defined methods.
The goal is to eliminate runtime method injection via decorators and
_make_aggopclosures, resulting in:Key Changes
1. Removed Dynamic GroupBy Operator Injection
Deleted:
groupby_operatorsdecoratorGROUPBY_REDUCTION_TYPESdependency indataframe.py_make_aggopclassmethod inDataFrameGroupBy_make_aggopclassmethod inDiffAggregateAggregation methods are now explicitly defined on both classes.
2. Introduced
_aggregateinDataFrameGroupByA shared
_aggregate(opname, colnames=None)method now handlesaggregation logic, including:
DataFrameresultsExplicit aggregation methods now include:
Special handling is provided for keyword conflicts:
or_()→ aliased toorand_()→ aliased toand3. Explicit Aggregations in
DiffAggregateReplaced closure-based
_make_aggopwith:_agg(opname)helperorandandThis makes the class fully declarative and avoids dynamic method
construction.
4. Removed
aggregation_operatorsDecorator fromSeriesDeleted:
aggregation_operatorsdecorator_make_aggopclassmethod inSeriesExplicitly implemented the following methods:
Each now directly delegates to
self.values.<op>().Behavioral Impact
Why This Change?
Dynamic method injection made the API surface harder to:
Explicit definitions make supported reductions obvious and future
modifications safer.
Testing
Existing groupby and series aggregation tests pass without modification.
No behavioral regressions expected.
Closes #5307: Replace _make_aggop with Explicit Aggregation Method Definitions