Skip to content

fix(calendar): preserve weekly and monthly periods in sparse calendars - #2366

Open
Oleg Zholobov (parlorsky) wants to merge 1 commit into
microsoft:mainfrom
parlorsky:olegzh/fix-sparse-calendar-resampling
Open

Oleg Zholobov (parlorsky) wants to merge 1 commit into
microsoft:mainfrom
parlorsky:olegzh/fix-sparse-calendar-resampling

Conversation

@parlorsky

@parlorsky Oleg Zholobov (parlorsky) commented Oct 7, 2026 •

Copy link
Copy Markdown

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-17 to 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 to 2week/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?

  • The upstream tests/test_all_pipeline.py suite: 3 passed (training, backtesting, experiment manager). Used a local runner to point TestAutoData at an isolated data directory; the test implementation was unchanged.
  • pytest tests/misc/test_resam.py tests/misc/test_utils.py -q: 11 passed.
  • Black and flake8 on the changed files using the project's settings; 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

  • Fix bugs
  • Add new feature
  • Update documentation

@parlorsky

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Zholobov Oleg (Zholobov Oleg (@parlorsky)) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

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.

1 participant