-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
IntervalIndex get_indexer may return -1 for values that are in the index #16410
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
Comments
@nateyoder welcome to have you take a look. |
@jreback sounds like your desired behavior for now is raising? If that is the case I can try to take a look. |
Agreed, |
actually so this is correct (though certainly may not be handled correctly elsewhere), where are you seeing this (aside from the top-example)?
|
The issue with this get_indexer call for IntervalIndex is that it returns -1 even though the interval IS in the index (as shown with the second assert in my example). If non-monotonic IntervalIndex objects are not handled in the code it seems to me like creating one should raise? |
@nateyoder sorry, you are right. this should return the right value, but |
Sometimes we raise a different error (e.g.,
pandas.errors.UnsortedIndexError) but in general we do try to avoid this.
…On Mon, May 22, 2017 at 10:02 AM Jeff Reback ***@***.***> wrote:
@nateyoder <https://github.com/nateyoder> sorry, you are right. this
should return the right value, but get_indexer() never raises by
definition. (the -1 indicate missing values)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16410 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKS1pBOqn-w0YSwIGIHRqRjHgxgmAZHks5r8b-egaJpZM4Nhwpx>
.
|
The bug is still here for non-monotonic index.
I guess this bug is due to that pandas/pandas/core/indexes/interval.py Lines 850 to 851 in a1fee91
Digging deeper into the pandas/pandas/_libs/intervaltree.pxi.in Line 358 in a1fee91
Becuase |
The original issue isn't fully copy pasteable, but @makbigc's examples look to work on master. Could use a test.
|
Code Sample, a copy-pastable example if possible
Problem description
I expected get_indexer on IntervalIndex is expected to return the index of matching values. However it does not always seem to do so.
Expected Output
In the above example I expected an output of a = np.array([1])
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: 4111382
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.21.0.dev+67.g4111382
pytest: 3.0.7
pip: 8.1.2
setuptools: 35.0.2
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.19.0
xarray: None
IPython: 5.1.0
sphinx: 1.4.8
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.2
feather: None
matplotlib: 2.0.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: 1.1.2
pymysql: 0.7.9.None
psycopg2: None
jinja2: 2.8
s3fs: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: