diff --git a/python/cudf/cudf/_lib/scalar.pyx b/python/cudf/cudf/_lib/scalar.pyx index af63964bac3..0ff736b9204 100644 --- a/python/cudf/cudf/_lib/scalar.pyx +++ b/python/cudf/cudf/_lib/scalar.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. cimport cython @@ -536,7 +536,7 @@ cdef _get_np_scalar_from_timedelta64(unique_ptr[scalar]& s): cdef scalar* s_ptr = s.get() if not s_ptr[0].is_valid(): - return None + return NA cdef libcudf_types.data_type cdtype = s_ptr[0].type() diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index ab45374c119..82ef309d116 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -1437,3 +1437,8 @@ def test_timdelta_binop_tz_timestamp(op): date_tz_scalar = datetime.datetime.now(datetime.timezone.utc) with pytest.raises(NotImplementedError): op(s, date_tz_scalar) + + +def test_timedelta_getitem_na(): + s = cudf.Series([1, 2, None, 3], dtype="timedelta64[ns]") + assert s[2] is cudf.NA