Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sinhrks opened this issue May 4, 2016 · 3 comments
Closed

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

sinhrks opened this issue May 4, 2016 · 3 comments
Labels
Bug Error Reporting Incorrect or improved errors from pandas Period Period data type Timedelta Timedelta data type
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented May 4, 2016

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

@sinhrks sinhrks added Bug Error Reporting Incorrect or improved errors from pandas Timedelta Timedelta data type Period Period data type labels May 4, 2016
@sinhrks sinhrks added this to the 0.18.2 milestone May 4, 2016
@max-sixty
Copy link
Contributor

show understandable error message.

I vote for this.
I can't think of a reasonable way there could be arithmetic between points-in-time and spans. Tenuously, we could convert a Period into a Timedelta and use that, but then the user could do that explicitly

@jreback
Copy link
Contributor

jreback commented May 4, 2016

I agree an error is best here - maybe show how to convert in the error message though

dfi and period arithmetic cannot be intermixed implicitly

@sinhrks
Copy link
Member Author

sinhrks commented Jul 7, 2016

This has been fixed by #13071, adding tests and release note.

nateGeorge pushed a commit to nateGeorge/pandas that referenced this issue Aug 15, 2016
closes pandas-dev#13078

Author: sinhrks <[email protected]>

Closes pandas-dev#13581 from sinhrks/dti_period_error and squashes the following commits:

c957541 [sinhrks] BUG: DatetimeIndex - Period shows ununderstandable error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Error Reporting Incorrect or improved errors from pandas Period Period data type Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants