Use flox for median in groupby/resample operations#11239
Open
sdiebolt wants to merge 2 commits intopydata:mainfrom
Open
Use flox for median in groupby/resample operations#11239sdiebolt wants to merge 2 commits intopydata:mainfrom
sdiebolt wants to merge 2 commits intopydata:mainfrom
Conversation
Add flox support to median() methods in: - DataArrayGroupByAggregations - DatasetGroupByAggregations - DataArrayResampleAggregations - DatasetResampleAggregations This aligns the implementation with the documentation which already claimed flox was used when available. The fix provides significant performance improvements when flox can process the data. A fallback to the non-flox implementation is included for cases where flox's median aggregation requires blockwise processing but the data chunking doesn't support it. Closes pydata#11238
dcherian
requested changes
Mar 17, 2026
Contributor
There was a problem hiding this comment.
Thanks for taking this on!
Let's raise Now that I think about it; we can do this in flox automatically: xarray-contrib/flox#501FutureWarning here asking the user to shuffle_to_chunks or rechunk appropriately and that this behaviour will be deprecated in 6 months (please open an issue for that).
The reason I hadn't done this so far is that dask will do some auto-rechunking to make it work; and so some workloads will break.
Also this file is generated by generate_aggregations.py. Please make the edit there instead
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.
Add flox support to median() methods in:
This aligns the implementation with the documentation which already claimed flox was used when available. The fix provides significant performance improvements when flox can process the data. A fallback to the non-flox implementation is included for cases where flox's median aggregation requires blockwise processing but the data chunking doesn't support it.
Closes #11238
whats-new.rst