Skip to content

Commit

Permalink
Fix timedelta null
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar committed Aug 11, 2023
1 parent b743cc7 commit aa6769f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/cudf/cudf/_lib/scalar.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2022, NVIDIA CORPORATION.
# Copyright (c) 2020-2023, NVIDIA CORPORATION.

cimport cython

Expand Down Expand Up @@ -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()

Expand Down
5 changes: 5 additions & 0 deletions python/cudf/cudf/tests/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit aa6769f

Please sign in to comment.