From ae2d585783c4df4c89e4eceacfdabd7c82678ec8 Mon Sep 17 00:00:00 2001 From: galipremsagar Date: Thu, 24 Aug 2023 17:48:51 -0700 Subject: [PATCH] Fix IntervalIndex.repr --- python/cudf/cudf/core/index.py | 3 +++ python/cudf/cudf/tests/test_repr.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index 458ef2df02d..a5ef1a523a4 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -3211,6 +3211,9 @@ def _is_interval(self): def _is_boolean(self): return False + def _clean_nulls_from_index(self): + return self + class StringIndex(GenericIndex): """String defined indices into another Column diff --git a/python/cudf/cudf/tests/test_repr.py b/python/cudf/cudf/tests/test_repr.py index b944e0483d0..a36cc1b3819 100644 --- a/python/cudf/cudf/tests/test_repr.py +++ b/python/cudf/cudf/tests/test_repr.py @@ -1469,3 +1469,16 @@ def test_repr_struct_after_concat(): pdf = df.to_pandas() assert repr(df) == repr(pdf) + + +def test_interval_index_repr(): + pi = pd.Index( + [ + np.nan, + pd.Interval(2.0, 3.0, closed="right"), + pd.Interval(3.0, 4.0, closed="right"), + ] + ) + gi = cudf.from_pandas(pi) + + assert repr(pi) == repr(gi)