Repository navigation
fix(calendar): preserve weekly and monthly periods in sparse calendars - #2366
Open
Oleg Zholobov (parlorsky) wants to merge 1 commit into
Open
Oleg Zholobov (parlorsky) wants to merge 1 commit into
Oleg Zholobov (parlorsky) wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree
@microsoft-github-policy-service agree |
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.
Description
Fix weekly and monthly calendar resampling when the source calendar has gaps or is already sampled at those frequencies. Determine period boundaries from complete calendar weeks/months, then keep the existing first-available-date and frequency-count behavior.
Motivation and Context
The current implementation detects a new week/month only when the weekday/day-of-month decreases. This silently drops periods when there are gaps: resampling
2024-01-01, 2024-01-02, 2024-01-09, 2024-01-10, 2024-01-17to weeks returns only January 1 instead of January 1, 9, and 17. Weekly inputs that always fall on Monday and monthly inputs that always fall on the first have the same problem when resampling to2week/2month.The regression cases cover sparse daily calendars, weekly/monthly inputs, year boundaries, intraday normalization, frequency counts, and empty calendars. Four cases fail on the original implementation.
How Has This Been Tested?
tests/test_all_pipeline.pysuite: 3 passed (training, backtesting, experiment manager). Used a local runner to pointTestAutoDataat an isolated data directory; the test implementation was unchanged.pytest tests/misc/test_resam.py tests/misc/test_utils.py -q: 11 passed.git diff --check.Environment: Python 3.12, macOS arm64, pandas 2.3.3, MLflow 3.12.0. The test runs emit existing deprecation/runtime warnings.
Types of changes