>> freq.is_on_offset(per.to_timestamp()) False >>> per Period('2023-04-06', 'C') The link betwe...">

BUG?: Period allows construction from Custom freqs · Issue #52534 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@jbrockmendel

Description

@jbrockmendel

freq = pd.offsets.CustomBusinessDay(weekmask="Mon Wed Fri")

per = pd.Period("2023-04-06", freq=freq)

freq.is_on_offset(per.to_timestamp()) False

per Period('2023-04-06', 'C')

The link between DateOffset and Period is a footgun. In this case, the Period machinery sees this CustomBusinessDay and doesn't distinguish between it and BusinessDay (of which CBDay is a subclass).

Probably should raise on CustomBusinessDay.