ENH: Raise TypeError for offsets which are not supported as period frequency by natmokval · Pull Request #55844 · pandas-dev/pandas (original) (raw)
@natmokval, does this PR also close: #5091 ?
@cancan101, I think, this PR doesn't close #5091. We still have the same behavior. For example, frequency changes from 'ME' to 'MS':
>>> ts = pd.date_range('1/1/2012', periods=4, freq=pd.offsets.MonthEnd())
>>> per = ts.to_period()
>>> ts_per = per.to_timestamp()
>>> ts
DatetimeIndex(['2012-01-31', '2012-02-29', '2012-03-31', '2012-04-30'], dtype='datetime64[ns]', freq='ME')
>>> per
PeriodIndex(['2012-01', '2012-02', '2012-03', '2012-04'], dtype='period[M]')
>>> ts_per
DatetimeIndex(['2012-01-01', '2012-02-01', '2012-03-01', '2012-04-01'], dtype='datetime64[ns]', freq='MS')