#[non_exhaustive]pub enum PeriodFreq {
Annual,
Quarterly,
Monthly,
Weekly,
Daily,
Business,
Hourly,
Minutely,
Secondly,
Milliseconds,
Microseconds,
Nanoseconds,
}Expand description
Period frequency code. Matches pandas offset alias core set.
The ordinal axis is frequency-specific: for Monthly, ordinal 0 is a
fixed anchor (pandas uses months since 1970-01). Phase 1 doesn’t
commit to a specific epoch yet — the ordinal scheme is opaque until
Phase 2 wires calendar arithmetic. What Phase 1 DOES nail down is:
same-freq Periods compare + subtract; Period + i64 shifts by n
periods of the declared frequency.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Annual
Y-DEC / A / Y — annual periods.
Quarterly
Q-DEC / Q — quarterly periods.
Monthly
M — monthly periods.
Weekly
W-SUN / W — weekly periods.
Daily
D — daily periods.
Business
B — business-day periods.
Hourly
h / H — hourly periods.
Minutely
min / T — minutely periods.
Secondly
s / S — secondly periods.
Milliseconds
ms — millisecond periods. NOT MS, which pandas reads as month start.
Microseconds
us / US — microsecond periods.
Nanoseconds
ns / NS — nanosecond periods.
Implementations§
Source§impl PeriodFreq
impl PeriodFreq
Sourcepub fn parse(alias: &str) -> Option<Self>
pub fn parse(alias: &str) -> Option<Self>
Parse a pandas-style frequency alias. Recognizes the common subset (Y-DEC/A/Y, Q-DEC/Q, M, W-SUN/W, D, B, h/H, min/T, s/S) plus the sub-second units ms, us/US, ns/NS.
Case-insensitive with ONE exception: bare MS is month start in pandas,
not milliseconds, and is refused here the way pandas refuses it for
to_period. See the check at the top of the body.
Sourcepub const fn resolution(self) -> Option<&'static str>
pub const fn resolution(self) -> Option<&'static str>
Resolution word for PeriodIndex.resolution, or None where pandas has
no answer.
⚠️ THIS IS NOT THE ALIAS TABLE. pandas’ .resolution names the period’s
component, in the same vocabulary DatetimeIndex::resolution already
uses here – it is not the frequency string, which is what
PeriodFreq::alias is for. MEASURED, live pandas 2.2.3, one-element
PeriodIndex per freq:
Y -> ‘year’ Q -> ‘quarter’ M -> ‘month’
D -> ‘day’ h -> ‘hour’ min-> ‘minute’
s -> ‘second’
W -> raises AttributeError
B -> raises AttributeError
Every arm below previously returned the alias instead (“A-DEC”, “M”, “H”,
“T”, “S”, …), so all nine disagreed with the incumbent; W and B answered
where pandas refuses. The refusal is modelled as None rather than a
wrong word, because the caller already returns Option for the empty
index and pandas’ own failure there is an absence, not a value.