Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
for i in range(n):
value = arr[i]
if value == NPY_NAT:
result[i] = NaT
result[i] = <object>NaT
else:
dt64_to_dtstruct(value, &dts)
result[i] = func_create(value, dts, tz, freq)
elif is_tzlocal(tz):
for i in range(n):
value = arr[i]
if value == NPY_NAT:
result[i] = NaT
result[i] = <object>NaT
else:
# Python datetime objects do not support nanosecond
# resolution (yet, PEP 564). Need to compute new value
Expand All @@ -152,7 +152,7 @@ def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
for i in range(n):
value = arr[i]
if value == NPY_NAT:
result[i] = NaT
result[i] = <object>NaT
else:
# Adjust datetime64 timestamp, recompute datetimestruct
dt64_to_dtstruct(value + delta, &dts)
Expand All @@ -164,7 +164,7 @@ def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
for i in range(n):
value = arr[i]
if value == NPY_NAT:
result[i] = NaT
result[i] = <object>NaT
else:
# Adjust datetime64 timestamp, recompute datetimestruct
pos = trans.searchsorted(value, side='right') - 1
Expand All @@ -175,7 +175,7 @@ def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
for i in range(n):
value = arr[i]
if value == NPY_NAT:
result[i] = NaT
result[i] = <object>NaT
else:
# Adjust datetime64 timestamp, recompute datetimestruct
pos = trans.searchsorted(value, side='right') - 1
Expand Down Expand Up @@ -439,11 +439,11 @@ def array_with_unit_to_datetime(ndarray values, object unit,
val = values[i]

if checknull_with_nat(val):
oresult[i] = NaT
oresult[i] = <object>NaT
elif is_integer_object(val) or is_float_object(val):

if val != val or val == NPY_NAT:
oresult[i] = NaT
oresult[i] = <object>NaT
else:
try:
oresult[i] = Timestamp(cast_from_unit(val, unit))
Expand All @@ -452,7 +452,7 @@ def array_with_unit_to_datetime(ndarray values, object unit,

elif isinstance(val, str):
if len(val) == 0 or val in nat_strings:
oresult[i] = NaT
oresult[i] = <object>NaT

else:
oresult[i] = val
Expand Down Expand Up @@ -816,7 +816,7 @@ cdef array_to_datetime_object(ndarray[object] values, str errors,
check_dts_bounds(&dts)
except (ValueError, OverflowError):
if is_coerce:
oresult[i] = NaT
oresult[i] = <object>NaT
continue
if is_raise:
raise
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def ints_to_pytimedelta(int64_t[:] arr, box=False):

value = arr[i]
if value == NPY_NAT:
result[i] = NaT
result[i] = <object>NaT
else:
if box:
result[i] = Timedelta(value)
Expand Down