File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -234,31 +234,37 @@ def maybe_convert_numeric(ndarray[object] values, set na_values):
234
234
cdef:
235
235
Py_ssize_t i, n
236
236
ndarray[float64_t] floats
237
+ ndarray[complex64_t] complexes
237
238
ndarray[int64_t] ints
238
239
bint seen_float = 0
240
+ bint seen_complex = 0
239
241
object val
240
242
float64_t fval
241
243
242
244
n = len (values)
243
245
244
246
floats = np.empty(n, dtype = ' f8' )
247
+ complexes = np.empty(n, dtype = ' c8' )
245
248
ints = np.empty(n, dtype = ' i8' )
246
249
247
250
for i from 0 <= i < n:
248
251
val = values[i]
249
252
250
253
if util.is_float_object(val):
251
- floats[i] = val
254
+ floats[i] = complexes[i] = val
252
255
seen_float = 1
253
256
elif val in na_values:
254
- floats[i] = nan
257
+ floats[i] = complexes[i] = nan
255
258
seen_float = 1
256
259
elif val is None :
257
- floats[i] = nan
260
+ floats[i] = complexes[i] = nan
258
261
seen_float = 1
259
262
elif len (val) == 0 :
260
- floats[i] = nan
263
+ floats[i] = complexes[i] = nan
261
264
seen_float = 1
265
+ elif util.is_complex_object(val):
266
+ complexes[i] = val
267
+ seen_complex = 1
262
268
else :
263
269
fval = util.floatify(val)
264
270
floats[i] = fval
@@ -268,7 +274,9 @@ def maybe_convert_numeric(ndarray[object] values, set na_values):
268
274
else :
269
275
ints[i] = < int64_t> fval
270
276
271
- if seen_float:
277
+ if seen_complex:
278
+ return complexes
279
+ elif seen_float:
272
280
return floats
273
281
else :
274
282
return ints
You can’t perform that action at this time.
0 commit comments