BUG/ERR: DatetimeIndex - Period shows ununderstandable error · Issue #13078 · pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example if possible

Split from #13071. DatetimeIndex - Period is not supported ATM, but errors are not understandable.

pd.DatetimeIndex(['2011-01-01', '2011-02-01']) - pd.Period('2011-01-01', freq='D') 
# ValueError: Cannot do arithmetic with non-conforming periods

pd.DatetimeIndex(['2011-01-01', '2011-01-02'], freq='D') - pd.Period('2011-01-01', freq='D') 
# AttributeError: 'DatetimeIndex' object has no attribute 'ordinal'

Expected Output

show understandable error message.

Or it should be supported converting Period to Timestamp.

pd.DatetimeIndex(['2011-01-01', '2011-02-01']) - pd.Period('2011-01-01', freq='D').to_timestamp()
# TimedeltaIndex(['0 days', '31 days'], dtype='timedelta64[ns]', freq=None)

output of pd.show_versions()

on current master