Skip to content

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

Closed
@jschendel

Description

@jschendel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions