feat: Add cum_mean Expression and Series method#26569
Open
alexander-beedie wants to merge 5 commits intopola-rs:mainfrom
Open
feat: Add cum_mean Expression and Series method#26569alexander-beedie wants to merge 5 commits intopola-rs:mainfrom
cum_mean Expression and Series method#26569alexander-beedie wants to merge 5 commits intopola-rs:mainfrom
Conversation
cum_mean Expressioncum_mean Expression and Series method
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #26569 +/- ##
==========================================
+ Coverage 81.38% 81.39% +0.01%
==========================================
Files 1792 1792
Lines 244414 244583 +169
Branches 3078 3078
==========================================
+ Hits 198913 199084 +171
+ Misses 44715 44713 -2
Partials 786 786 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
wence-
reviewed
Feb 16, 2026
dda8a25 to
496bd9c
Compare
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.
Also closes #26065.
Been working on this one on & off for a few weeks; ready for review 🤔
Since we need to track state for two variables, added a
CumAggStateenum......with all the existing cumulative exprs using the single-value option, and mean using the new
CumMeanState, which tracks the sum and count vars (for float and -if indicated- decimal). Can extend in the future if any other aggregate functions need additional state tracking.The cumulative mean calculation itself is relatively unexciting (though there is a dedicated
Decimalpath, patterned after the same in the other cumulative funcs). It got much better this morning when I found the existingKahanSumstruct and was able to (almost) just drop it right in, making the overall implementation feel much improved 👍We had (relatively) little dedicated cumulative expression coverage, so I added more in a new
test_cumulative.pyfile, covering additional validations such as streaming vs in-memory, optimised/unoptimised,nanpoisoning,infbehaviour, and the full range of int/float/temporal dtypes (slightly over half of this PR is just new test coverage).🤖 AI: Claude Code (Opus 4.6) helped identify test coverage gaps and provided the initial unit test skeleton, which I then industrialised and made more idiomatic.