diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index 3d77ed15027..5b101f74664 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -118,6 +118,11 @@ def _index_from_data(data: MutableMapping, name: Any = None): index_class_type = CategoricalIndex elif isinstance(values, (IntervalColumn, StructColumn)): index_class_type = IntervalIndex + else: + raise NotImplementedError( + "Unsupported column type passed to " + f"create an Index: {type(values)}" + ) else: index_class_type = cudf.MultiIndex return index_class_type._from_data(data, name) diff --git a/python/cudf/cudf/tests/test_index.py b/python/cudf/cudf/tests/test_index.py index 358d5e2170e..894c87add4b 100644 --- a/python/cudf/cudf/tests/test_index.py +++ b/python/cudf/cudf/tests/test_index.py @@ -2783,3 +2783,15 @@ def test_index_null_values(): gidx = cudf.Index([1.0, None, 3, 0, None]) with pytest.raises(ValueError): gidx.values + + +def test_index_error_list_index(): + s = cudf.Series([[1, 2], [2], [4]]) + with pytest.raises( + NotImplementedError, + match=re.escape( + "Unsupported column type passed to create an " + "Index: " + ), + ): + cudf.Index(s)