Skip to content

Commit e7b36bc

Browse files
committed
BUG: don't convert Python long to float
1 parent 829e9e5 commit e7b36bc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/io/tests/test_parsers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ def test_convert_sql_column_ints(self):
246246
expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
247247
assert_same_values_and_dtype(result, expected)
248248

249+
def test_convert_sql_column_longs(self):
250+
arr = np.array([1L, 2L, 3L, 4L], dtype='O')
251+
result = lib.convert_sql_column(arr)
252+
expected = np.array([1, 2, 3, 4], dtype='i8')
253+
assert_same_values_and_dtype(result, expected)
254+
255+
arr = np.array([1L, 2L, 3L, None, 4L], dtype='O')
256+
result = lib.convert_sql_column(arr)
257+
expected = np.array([1, 2, 3, np.nan, 4], dtype='f8')
258+
assert_same_values_and_dtype(result, expected)
259+
249260
def test_convert_sql_column_bools(self):
250261
arr = np.array([True, False, True, False], dtype='O')
251262
result = lib.convert_sql_column(arr)

pandas/src/parsing.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def convert_sql_column(ndarray[object] objects):
126126
elif cpython.PyBool_Check(val):
127127
seen_bool = 1
128128
bools[i] = val
129-
elif cpython.PyInt_Check(val):
129+
elif cpython.PyInt_Check(val) or cpython.PyLong_Check(val):
130130
seen_int = 1
131131
floats[i] = <float64_t> val
132132
if not seen_null:

0 commit comments

Comments
 (0)