Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ Interval
^^^^^^^^

- Construction of :class:`Interval` is restricted to numeric, :class:`Timestamp` and :class:`Timedelta` endpoints (:issue:`23013`)
-
- Fixed bug in :class:`Series`/:class:`DataFrame` not displaying ``NaN`` in :class:`IntervalIndex` with missing values (:issue:`25984`)
-

Indexing
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def __getitem__(self, value):
def _format_with_header(self, header, **kwargs):
return header + list(self._format_native_types(**kwargs))

def _format_native_types(self, na_rep='', quoting=None, **kwargs):
def _format_native_types(self, na_rep='NaN', quoting=None, **kwargs):
""" actually format my specific types """
from pandas.io.formats.format import ExtensionArrayFormatter
return ExtensionArrayFormatter(values=self,
Expand Down
17 changes: 17 additions & 0 deletions pandas/tests/indexes/interval/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,23 @@ def test_frame_repr(self):
)
assert result == expected

@pytest.mark.parametrize('constructor,expected', [
(pd.Series, ('(0.0, 1.0] a\n'
'NaN b\n'
'(2.0, 3.0] c\n'
'dtype: object')),
(pd.DataFrame, (' 0\n'
'(0.0, 1.0] a\n'
'NaN b\n'
'(2.0, 3.0] c'))
])
def test_repr_missing(self, constructor, expected):
# GH 25984
index = IntervalIndex.from_tuples([(0, 1), np.nan, (2, 3)])
obj = constructor(list('abc'), index=index)
result = repr(obj)
assert result == expected

# TODO: check this behavior is consistent with test_interval_new.py
def test_get_item(self, closed):
i = IntervalIndex.from_arrays((0, 1, np.nan), (1, 2, np.nan),
Expand Down