xarray icon indicating copy to clipboard operation
xarray copied to clipboard

drop_incomplete support in SeasonGrouper

Open dhruvak001 opened this issue 5 months ago • 1 comments

  • [x] Closes #10426
  • [ ] Tests added
  • [ ] User visible changes (including notable bug fixes) are documented in whats-new.rst
  • [ ] New functions/methods are listed in api.rst

SeasonGrouper Enhancements

Enhanced the SeasonGrouper class to support conditional omission of incomplete seasons—now aligned with behavior in SeasonResampler.


Summary of Changes

1. drop_incomplete Keyword Argument

  • Introduced a new boolean parameter drop_incomplete, defaulting to False for backward compatibility.
  • Enables users to choose whether incomplete seasons should be excluded during grouping.

2. Revised factorize Method

  • Core logic for dropping incomplete seasons has been moved into the factorize method.
  • When drop_incomplete=True, it:
    • Iterates over each year-series chunk.
    • Verifies that all expected months in the season are present.
    • Excludes any data for that season-year pair if months are missing.

3. Updated reset Method

  • Ensures that the drop_incomplete setting correctly propagates when resetting or re-initializing the grouper.

dhruvak001 avatar Jun 21 '25 10:06 dhruvak001

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. If you have questions, some answers may be found in our contributing guidelines.

welcome[bot] avatar Jun 21 '25 10:06 welcome[bot]

@dcherian the failing tests seems to be unrelated to changes in the PR, right?

dhruvak001 avatar Jul 04 '25 03:07 dhruvak001

Yes.

Apologies, I am quite busy at the moment and can only review this in two weeks.

@tomvothecoder if you happen to have tests for grouping with drop_incomplete, those would be very helpful here.

dcherian avatar Jul 04 '25 03:07 dcherian