BUG: Fix Period and PeriodIndex support of combined offsets aliases by agraboso · Pull Request #13874 · pandas-dev/pandas (original) (raw)
Rebased. I have also added tests for Period, Period.asfreq, PeriodIndex, PeriodIndex.asfreq, PeriodIndex.to_datetime and period_range with combined aliases.
There is one standing issue: the function get_standard_freq() does not accepted combined aliases as of now. Apart from tests, it is only called from three places in the whole codebase:
- Lines period.py#L609 and period.pyx#L742 both read
freqstr = frequencies.get_standard_freq(other) They can — and should — be changed to
freqstr = other.rule_code
freq = Period._maybe_convert_freq(freq)
freq = frequencies.get_standard_freq(freq) can — and should — be changed to
freq = Period._maybe_convert_freq(freq).freqstr In view of this, I propose deprecating get_standard_freq() (as is already done with get_offset_name()) — or removing it completely if possible.