Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend TimeSeries.resample() to support more resampling methods #2643

Closed
wants to merge 0 commits into from

Conversation

jonasblanc
Copy link
Contributor

Checklist before merging this PR:

  • Mentioned all issues that this PR fixes or addresses.
  • Summarized the updates of this PR under Summary.
  • Added an entry under Unreleased in the Changelog.

Fixes #699

Summary

  • Expose all aggregation functions of xarray.DataArrayResample through the "method" argument of TimeSeries.resample().
  • Let users specify method specific arguments through method_args.
  • Extend tests with at least one test per additional method.

Other Information

  • Not all methods make sense for either down/up-sampling. I chose not to restrict the use of such methods in situation where they are not expected to be used (ie. xarray is responsible for handling such case). However while testing I encountered this bug: issue xarray asfreq which happens when asfreq is used for down-sampling.
  • I chose to give access to any() and all() aggregation methods, to be consistent with TimeSeries, I cast bool back to int after the aggregation.
  • I chose to let pad as the default method so as not to break the default behavior, even though it's not the most intuitive method for down-sampling.

Copy link
Collaborator

@madtoinou madtoinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice contribution @jonasblanc, some minor comments to improve the readibility

darts/timeseries.py Outdated Show resolved Hide resolved
darts/timeseries.py Outdated Show resolved Hide resolved
darts/timeseries.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.17%. Comparing base (c52ec83) to head (c16d0dd).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2643      +/-   ##
==========================================
- Coverage   94.20%   94.17%   -0.04%     
==========================================
  Files         141      141              
  Lines       15491    15493       +2     
==========================================
- Hits        14594    14591       -3     
- Misses        897      902       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@dennisbader dennisbader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice PR, thanks and great job @jonasblanc 🚀 Just had some minor suggestions, after that we're ready to merge :)

darts/timeseries.py Outdated Show resolved Hide resolved
darts/timeseries.py Outdated Show resolved Hide resolved
darts/timeseries.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@madtoinou madtoinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great first contribution @jonasblanc! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend TimeSeries.resample() to be more like pandas resample()
3 participants