Repository navigation
Conversation
Contributor
Test Results 1 files ± 0 1 suites ±0 1m 56s ⏱️ -14s Results for commit baf6ec8. ± Comparison against base commit 48b6ea1. This pull request removes 10 and adds 29 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #286 +/- ##
==========================================
+ Coverage 93.83% 93.87% +0.04%
==========================================
Files 203 203
Lines 22488 22677 +189
Branches 1458 1489 +31
==========================================
+ Hits 21101 21289 +188
- Misses 1099 1100 +1
Partials 288 288 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ptomecek
force-pushed
the
feature/optional-pandas-frequency
branch
6 times, most recently
from
October 29, 2026 19:48
fca3c80 to
cc82137
Compare
pip install ccflow no longer installs pandas. Frequency, the context classes, normalize_date/normalize_datetime and dates_to_chunks are pure Python; PandasResult, XArrayResult, PandasFilePublisher and Frequency.offset import pandas when used, and pandas moves to the full, develop and test extras. Frequency is a value type whose canonical string is a count and a polars unit (ns, us, ms, s, m, h, d, w, mo, q, y) with the polars meaning: ns to h are fixed durations and d, w, mo, q, y are calendar units, so 1d and 24h are distinct. Equal values share one spelling (60m -> 1h, 3mo -> 1q). Frequency parses, validates and converts (n, unit, .timedelta, .offset) and does no date arithmetic: - normalize_date and normalize_datetime shift relative dates by mo/q/y keeping the day of month (polars offset_by); normalize_date accepts only calendar units. - dates_to_chunks returns polars truncate buckets counted from 1970-01-01 (weeks from Monday 1970-01-05). Chunks from 1970 on are unchanged, and multi-period chunks before 1970 now work. The pandas spellings T, min, H, S, L, U, N and D are accepted with a FutureWarning; ISO-8601 durations, timedeltas and pandas offsets are accepted and normalized. M is rejected as ambiguous, and pandas period-end, anchored, period-start, business-day and semi-month spellings and offsets are rejected because they have no equivalent. Frequency.offset returns pandas ticks, Day(n), Week(n) or DateOffset(n, months=k). PandasFilePublisher validates data without importing pandas, and the installation guide notes that pandas is optional. This is a breaking change; the pull request lists every change in behaviour. Signed-off-by: Pascal Tomecek <40371786+ptomecek@users.noreply.github.com>
ptomecek
force-pushed
the
feature/optional-pandas-frequency
branch
from
October 29, 2026 22:34
cc82137 to
baf6ec8
Compare
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
This makes pandas an optional dependency. So that ccflow is not coupled to another library,
Frequencygets its own implementation, which follows the polars duration language. It is a breaking change and should be released as 0.10.0.pip install ccflowno longer installs pandas.Frequency, the context classes,normalize_date/normalize_datetimeanddates_to_chunksare pure Python and work without pandas;PandasResult,XArrayResult,PandasFilePublisherandFrequency.offsetimport pandas when used.Frequencyis now a value type. Its canonical string is an integer count and a polars unit (ns,us,ms,s,m,h,d,w,mo,q,y), e.g.5m,1h,1d,1mo, and the units mean what they mean in polars:nstohare fixed durations andd,w,mo,q,yare calendar units, so1dand24hare distinct. Equal values share one spelling (60m->1h,3mo->1q).Frequencyparses, validates and converts (n,unit,.timedelta,.offset) but does no date arithmetic: relative dates innormalize_date/normalize_datetimeshift bymo/q/ykeeping the day of month (polarsoffset_by), anddates_to_chunksreturns polarstruncatebuckets.IntradayFrequencyandCalendarFrequencyrestrict a field to sub-day or calendar frequencies.The pandas spellings
T,min,H,S,L,U,NandDare still accepted in any case, with aFutureWarning. ISO-8601 durations with integer components (PT5M,P1M), timedeltas and pandas offsets are also accepted and normalized. Other pandas spellings are rejected, as listed below.Breaking changes
Installation
pip install ccflowno longer installs pandas. Code that usesPandasResult,XArrayResult,PandasFilePublisherorFrequency.offset, or that relied on ccflow to bring in pandas, must depend on pandas directly or installccflow[full].Strings that still parse but change meaning, with no warning (search configs for lowercase
m,q,yandwbefore upgrading)mwas month-end and is now minute:Frequency.validate("5m")was5MEand is now five minutes, and on 2026-10-15normalize_datetime("-6m")was 2026-04-30 and is now 2026-10-14 23:54.normalize_dateaccepts only calendar units, sonormalize_date("-6m")now raises.yandqin relative dates moved to the year or quarter end and now keep the day of month: on 2026-10-15,normalize_date("1y")was 2026-12-31 and is now 2027-10-15, andnormalize_date("-1q")was 2026-09-30 and is now 2026-07-15. Likewisenormalize_date("-1mo")is 2026-09-15, where main's-1MEgave 2026-09-30.wrolled to the next Sunday and is now a seven-day step: on 2026-10-15,normalize_date("1w")was 2026-10-18 and is now 2026-10-22.Canonical strings and stored values
1D->1d,5min->5m,60min->1h,1440min->24h,0D->0s).Frequencyis astrsubclass, so this is the value in model dumps, cache keys and path templates; caches keyed on aFrequencymust be regenerated.1W-SUN,1ME,1QE-DEC,1YE-DEC,1B) fail validation; rewrite them as1w,1mo,1q,1y. Pickles written by main load but keep the old string and pandas offset; regenerate them.Frequency("1d")): a legacy default keeps its old string in dumps and cache keys and fails on first use of.n/.unit.ctx.freq == "1D") are now false.Rejected inputs
Mis ambiguous (usemofor month ormfor minute). Canonical units are case-sensitive:US,NSand mixed-caseMs/mS(micro-, nano- and milliseconds on main) are rejected; writeus,ns,ms.ME,QE,YE,A, uppercaseQ/Y/W, any anchor suffix (QE-DEC,YE-JUN,W-SUN,W-MON),B,BH,BME,MS,QS,SM. Usemo,q,yandw. The matching offsets (MonthEnd,QuarterEnd,YearEnd,Week(weekday=6),BusinessDay,MonthBegin) are rejected too.1d12h,1h30min,1.5h) are rejected; write36horPT36H. A timedelta that is not a whole number of days becomes a fixed duration (timedelta(hours=36)->36h).normalize_dateaccepts only calendar units (d,w,mo,q,y), so sub-day relative dates such as-1hraise.normalize_datetimestill accepts every unit.Frequency.offsetnstohgive pandas ticks,dgivesDay(n),wgives an unanchoredWeek(n)(main gaveWeek(n, weekday=6), so adding it rolled to Sunday), andmo/q/ygiveDateOffset(n, months=k)instead ofMonthEnd/QuarterEnd/YearEnd. Because values are reduced,.offsetfollows the reduced unit:60minnow givesHour(1), notMinute(60)..offsetis for adding to a timestamp.DateOffsetis not a pandas frequency:resamplerejects it, anddate_rangeapplies it step by step, so month-end dates drift (Jan 31, Feb 29, Mar 29). AFrequencystring is not a pandas alias either: pandas 2 reads5mas five month-ends and pandas 3 rejects5mand1mo.1Dand pandasDay()are read as the calendar day1d, although pandas 2 treatsDayas a fixed 24 hours.1nshas no.timedelta(main returned a zero timedelta).dates_to_chunks1h,5min,24h; main returned malformed chunks) and for main's spellingsM,MEand2W; the default is now spelled1mo. Fiscal-year (YE-JUN),W-MONand business-day chunking are gone.[]whenstart > end, and multi-period sizes (2mo,2w,3y) now work for ranges before 1970 (main returned[]).Warnings
5min,5T,1D,D) emit aFutureWarningnaming the canonical form, including in relative dates (date="-1D"); under-W errorthis is raised from model construction. No removal version is set. Canonical units are coerced silently, including signs, leading zeros, padding and reductions (+01d->1d,60m->1h).PandasFilePublisherdatais validated without importing pandas, anddata=Noneis now accepted.Type of Change
Breaking change: release as 0.10.0.
Checklist
make lint)make test)