Skip to content

BUG/ERR: DatetimeIndex - Period shows ununderstandable error #13078

Closed
@sinhrks

Description

@sinhrks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugError ReportingIncorrect or improved errors from pandasPeriodPeriod data typeTimedeltaTimedelta data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions