CLN: enforce deprecation of frequencies deprecated for offsets by natmokval · Pull Request #57986 · pandas-dev/pandas (original) (raw)
cool, I think this is on the right track
I think there's a logic error somewhere, as it currently gives
In [7]: pd.period_range('2000', periods=3, freq='s')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File offsets.pyx:4853, in pandas._libs.tslibs.offsets.to_offset()
ValueError: 's' is not supported as period frequency.
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
Cell In[7], line 1
----> 1 pd.period_range('2000', periods=3, freq='s')
File ~/pandas-dev/pandas/core/indexes/period.py:585, in period_range(start, end, periods, freq, name)
582 if freq is None and (not isinstance(start, Period) and not isinstance(end, Period)):
583 freq = "D"
--> 585 data, freq = PeriodArray._generate_range(start, end, periods, freq)
586 dtype = PeriodDtype(freq)
587 data = PeriodArray(data, dtype=dtype)
File ~/pandas-dev/pandas/core/arrays/period.py:321, in PeriodArray._generate_range(cls, start, end, periods, freq)
318 periods = dtl.validate_periods(periods)
320 if freq is not None:
--> 321 freq = Period._maybe_convert_freq(freq)
323 if start is not None or end is not None:
324 subarr, freq = _get_ordinal_range(start, end, periods, freq)
File period.pyx:1768, in pandas._libs.tslibs.period._Period._maybe_convert_freq()
File offsets.pyx:4914, in pandas._libs.tslibs.offsets.to_offset()
ValueError: Invalid frequency: s, failed to parse with error message: ValueError("'s' is not supported as period frequency.")
but 's' should definitely be supported here, right?