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

BUG: Series/DataFrame with IntervalIndex doesn't display NaN in index #25984

Closed
jschendel opened this issue Apr 4, 2019 · 1 comment

Comments

@jschendel
Copy link
Member

commented Apr 4, 2019

Code Sample, a copy-pastable example if possible

The index in Out[3] is does not display NaN:

In [1]: import numpy as np; import pandas as pd; pd.__version__
Out[1]: '0.25.0.dev0+359.gcaad3b5e5'

In [2]: ii = pd.IntervalIndex.from_tuples([(0, 1), np.nan, (2, 3)])

In [3]: pd.Series(list('abc'), index=ii)
Out[3]: 
(0.0, 1.0]    a
              b
(2.0, 3.0]    c
dtype: object

Note that this isn't an issue when the Series has Interval values, or when printing the index itself:

In [4]: pd.Series(ii)
Out[4]: 
0    (0.0, 1.0]
1           NaN
2    (2.0, 3.0]
dtype: interval

In [5]: ii
Out[5]: 
IntervalIndex([(0.0, 1.0], nan, (2.0, 3.0]],
              closed='right',
              dtype='interval[float64]')

This does not appear to be an issue with other types of index and was working in 0.23.4.

Problem description

The output index in Out[3] is missing NaN for the second entry and is instead blank.

Expected Output

I'd expect NaN to be displayed in the index.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: caad3b5
python: 3.7.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.19.14-041914-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.25.0.dev0+359.gcaad3b5e5
pytest: 4.3.1
pip: 19.0.3
setuptools: 40.8.0
Cython: 0.29.6
numpy: 1.16.2
scipy: 1.2.1
pyarrow: 0.11.1
xarray: 0.11.3
IPython: 7.3.0
sphinx: 1.8.5
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: 3.5.1
numexpr: 2.6.9
feather: None
matplotlib: 3.0.3
openpyxl: 2.6.1
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.5
lxml.etree: 4.3.2
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.3.1
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: 0.2.0
fastparquet: 0.2.1
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@simonjayhawkins

This comment has been minimized.

Copy link
Member

commented Apr 5, 2019

@jschendel : in 0.23.4 the missing values were displayed as nan in an IntervalIndex and the repr of the index itself and only print as NaN in a column of values with dtype object

>>> import numpy as np; import pandas as pd; pd.__version__
'0.23.4'
>>> ii = pd.IntervalIndex.from_tuples([(0, 1), np.nan, (2, 3)])
>>> pd.Series(list('abc'), index=ii)
(0.0, 1.0]    a
nan           b
(2.0, 3.0]    c
dtype: object
>>> pd.Series(ii)
0    (0.0, 1.0]
1           NaN
2    (2.0, 3.0]
dtype: object
>>> ii
IntervalIndex([(0.0, 1.0], nan, (2.0, 3.0]]
              closed='right',
              dtype='interval[float64]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.