diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 41fbf269699..908347e389b 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -595,8 +595,10 @@ def __init__( data = data.copy(deep=True) name_from_data = data.name column = as_column(data, nan_as_null=nan_as_null, dtype=dtype) - if isinstance(data, (pd.Series, Series)): + if isinstance(data, pd.Series): index_from_data = as_index(data.index) + elif isinstance(data, Series): + index_from_data = data.index elif isinstance(data, ColumnAccessor): raise TypeError( "Use cudf.Series._from_data for constructing a Series from " diff --git a/python/cudf/cudf/tests/test_series.py b/python/cudf/cudf/tests/test_series.py index 9aeae566730..323716d5fc3 100644 --- a/python/cudf/cudf/tests/test_series.py +++ b/python/cudf/cudf/tests/test_series.py @@ -2835,3 +2835,9 @@ def test_timedelta_series_init(data): actual = cudf.Series(scalar) assert_eq(expected, actual) + + +def test_series_from_series_index_no_shallow_copy(): + ser1 = cudf.Series(range(3), index=list("abc")) + ser2 = cudf.Series(ser1) + assert ser1.index is ser2.index