Skip to content

Commit d11eea2

Browse files
committed
BUG: in maybe_convert_numeric, if you've seen an 'inf', you've seen a float
1 parent 6f31f8c commit d11eea2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pandas/src/inference.pyx

+2
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ def maybe_convert_numeric(ndarray[object] values, set na_values,
359359
if not seen_float:
360360
if '.' in val:
361361
seen_float = 1
362+
elif 'inf' in val: # special case to handle +/-inf
363+
seen_float = 1
362364
else:
363365
ints[i] = <int64_t> fval
364366

pandas/tests/test_tseries.py

+5
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ def test_convert_objects():
290290
result = lib.maybe_convert_objects(arr)
291291
assert(result.dtype == np.object_)
292292

293+
def test_convert_infs():
294+
arr = np.array(['inf', 'inf', 'inf'], dtype='O')
295+
result = lib.maybe_convert_numeric(arr, set(), False)
296+
assert(result.dtype == np.float64)
297+
293298
def test_convert_objects_ints():
294299
# test that we can detect many kinds of integers
295300
dtypes = ['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8']

0 commit comments

Comments
 (0)