diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index 500fc580097..fc35ffa3744 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -1456,6 +1456,7 @@ def __repr__(self): pd_preprocess.dtype._categories = ( preprocess.categories.to_pandas() ) + pd_preprocess.dtype._ordered = preprocess.dtype.ordered cats_repr = repr(pd_preprocess).split("\n") output = "\n".join(data_repr[:-1] + cats_repr[-1:]) diff --git a/python/cudf/cudf/tests/test_repr.py b/python/cudf/cudf/tests/test_repr.py index 57eef9e3463..681b467f66c 100644 --- a/python/cudf/cudf/tests/test_repr.py +++ b/python/cudf/cudf/tests/test_repr.py @@ -1491,3 +1491,11 @@ def test_large_unique_categories_repr(): with utils.cudf_timeout(2, timeout_message="Failed to repr fast enough"): actual_repr = repr(gi) assert expected_repr == actual_repr + + +@pytest.mark.parametrize("ordered", [True, False]) +def test_categorical_index_ordered(ordered): + pi = pd.CategoricalIndex(range(10), ordered=ordered) + gi = cudf.CategoricalIndex(range(10), ordered=ordered) + + assert repr(pi) == repr(gi)