Skip to content
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

Change IntervalIndex set-ops error code type #19329

Merged

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Jan 21, 2018

Set operations (union, difference...) on IntervalIndex with incompatible index types will now raise a TypeError rather than a ValueError.

This PR is needed to make the changes requested in #19021.

EDIT: I've improved the error message also. Previously, you'd get:

>>> pd.IntervalIndex.from_breaks([0,1,2,3]).union(pd.RangeIndex(3))
ValueError: can only do set operations between two IntervalIndex objects that are closed on the same side

Which made no sense in this case. Now we get:

>>> pd.IntervalIndex.from_breaks([0,1,2,3]).union(pd.RangeIndex(3))
TypeError: the other index needs to be an IntervalIndex too, but was type RangeIndex

@topper-123 topper-123 force-pushed the Interval.py_ValueError_to_TypeError_II branch 2 times, most recently from fefdb8d to 549ab20 Compare January 21, 2018 06:05
@topper-123 topper-123 changed the title Change IntervalIndex set-ops eror code type Change IntervalIndex set-ops error code type Jan 21, 2018
@codecov
Copy link

codecov bot commented Jan 21, 2018

Codecov Report

Merging #19329 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19329      +/-   ##
==========================================
+ Coverage   91.53%   91.53%   +<.01%     
==========================================
  Files         150      150              
  Lines       48739    48741       +2     
==========================================
+ Hits        44612    44614       +2     
  Misses       4127     4127
Flag Coverage Δ
#multiple 89.9% <100%> (ø) ⬆️
#single 41.72% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/interval.py 92.4% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1245f06...c75e6de. Read the comment docs.

@topper-123 topper-123 force-pushed the Interval.py_ValueError_to_TypeError_II branch from 549ab20 to c75e6de Compare January 21, 2018 13:09
@jreback jreback added Error Reporting Incorrect or improved errors from pandas Interval Interval data type labels Jan 21, 2018
@jreback jreback added this to the 0.23.0 milestone Jan 21, 2018
@jreback jreback merged commit 4003a74 into pandas-dev:master Jan 21, 2018
@jreback
Copy link
Contributor

jreback commented Jan 21, 2018

thanks @topper-123

can rebase #19021 and tests should be much simpler. ping when ready on that one.

@topper-123 topper-123 deleted the Interval.py_ValueError_to_TypeError_II branch January 22, 2018 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Interval Interval data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants