Skip to content

Commit 5cab4d6

Browse files
jbrockmendeljreback
authored andcommitted
BLD: fix build warnings in tslib by casting explicitly to object (#26758)
1 parent 0f3e8e8 commit 5cab4d6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pandas/_libs/tslib.pyx

+9-9
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
127127
for i in range(n):
128128
value = arr[i]
129129
if value == NPY_NAT:
130-
result[i] = NaT
130+
result[i] = <object>NaT
131131
else:
132132
dt64_to_dtstruct(value, &dts)
133133
result[i] = func_create(value, dts, tz, freq)
134134
elif is_tzlocal(tz):
135135
for i in range(n):
136136
value = arr[i]
137137
if value == NPY_NAT:
138-
result[i] = NaT
138+
result[i] = <object>NaT
139139
else:
140140
# Python datetime objects do not support nanosecond
141141
# resolution (yet, PEP 564). Need to compute new value
@@ -152,7 +152,7 @@ def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
152152
for i in range(n):
153153
value = arr[i]
154154
if value == NPY_NAT:
155-
result[i] = NaT
155+
result[i] = <object>NaT
156156
else:
157157
# Adjust datetime64 timestamp, recompute datetimestruct
158158
dt64_to_dtstruct(value + delta, &dts)
@@ -164,7 +164,7 @@ def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
164164
for i in range(n):
165165
value = arr[i]
166166
if value == NPY_NAT:
167-
result[i] = NaT
167+
result[i] = <object>NaT
168168
else:
169169
# Adjust datetime64 timestamp, recompute datetimestruct
170170
pos = trans.searchsorted(value, side='right') - 1
@@ -175,7 +175,7 @@ def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
175175
for i in range(n):
176176
value = arr[i]
177177
if value == NPY_NAT:
178-
result[i] = NaT
178+
result[i] = <object>NaT
179179
else:
180180
# Adjust datetime64 timestamp, recompute datetimestruct
181181
pos = trans.searchsorted(value, side='right') - 1
@@ -439,11 +439,11 @@ def array_with_unit_to_datetime(ndarray values, object unit,
439439
val = values[i]
440440

441441
if checknull_with_nat(val):
442-
oresult[i] = NaT
442+
oresult[i] = <object>NaT
443443
elif is_integer_object(val) or is_float_object(val):
444444

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

453453
elif isinstance(val, str):
454454
if len(val) == 0 or val in nat_strings:
455-
oresult[i] = NaT
455+
oresult[i] = <object>NaT
456456

457457
else:
458458
oresult[i] = val
@@ -816,7 +816,7 @@ cdef array_to_datetime_object(ndarray[object] values, str errors,
816816
check_dts_bounds(&dts)
817817
except (ValueError, OverflowError):
818818
if is_coerce:
819-
oresult[i] = NaT
819+
oresult[i] = <object>NaT
820820
continue
821821
if is_raise:
822822
raise

pandas/_libs/tslibs/timedeltas.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def ints_to_pytimedelta(int64_t[:] arr, box=False):
117117

118118
value = arr[i]
119119
if value == NPY_NAT:
120-
result[i] = NaT
120+
result[i] = <object>NaT
121121
else:
122122
if box:
123123
result[i] = Timedelta(value)

0 commit comments

Comments
 (0)