You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using interval indices and using .reindex to index with missing labels (as suggested in the docs). However, it looks like if there are more than 100 rows in the index, when I .reindex with a missing key, i.e. np.nan, .reindex will return an unexpected non-null value. Since np.nan is not defined in the index, I would expect .reindex to return np.nan. But instead, it looks like value of a middle key is returned. When there are 100 rows or fewer, when I pass np.nan I get back what I expect, np.nan
benlawson
changed the title
BUG: unexpected value returned when .reindexing on a pd.IntervalIndex when using np.nan as an index value
BUG: unexpected value returned when .reindexing on a pd.Series with a pd.IntervalIndex when using np.nan as an index value
Mar 7, 2023
DeaMariaLeon
added
Indexing
Related to indexing on series/frames, not to indexes themselves
and removed
Needs Triage
Issue that has not been reviewed by a pandas team member
labels
Mar 25, 2023
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I am using interval indices and using
.reindex
to index with missing labels (as suggested in the docs). However, it looks like if there are more than 100 rows in the index, when I.reindex
with a missing key, i.e.np.nan
,.reindex
will return an unexpected non-null value. Sincenp.nan
is not defined in the index, I would expect.reindex
to returnnp.nan
. But instead, it looks like value of a middle key is returned. When there are 100 rows or fewer, when I passnp.nan
I get back what I expect,np.nan
Expected Behavior
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.10.9.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-197-generic
Version : #208-Ubuntu SMP Tue Nov 1 17:23:37 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.3
numpy : 1.24.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 65.6.3
pip : 23.0.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.11.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: