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
2 changes: 1 addition & 1 deletion pandas/src/inference.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
floats[i] = <float64_t> val
complexes[i] = <double complex> val
if not seen_null:
seen_uint = seen_uint or (val > npy_int64_max)
seen_uint = seen_uint or (int(val) > npy_int64_max)
seen_sint = seen_sint or (val < 0)

if seen_uint and seen_sint:
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/types/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ def test_maybe_convert_objects_uint64(self):
exp = np.array([2**63], dtype=np.uint64)
tm.assert_numpy_array_equal(lib.maybe_convert_objects(arr), exp)

# NumPy bug: can't compare uint64 to int64, as that
# results in both casting to float64, so we should
# make sure that this function is robust against it
arr = np.array([np.uint64(2**63)], dtype=object)
exp = np.array([2**63], dtype=np.uint64)
tm.assert_numpy_array_equal(lib.maybe_convert_objects(arr), exp)

arr = np.array([2, -1], dtype=object)
exp = np.array([2, -1], dtype=np.int64)
tm.assert_numpy_array_equal(lib.maybe_convert_objects(arr), exp)
Expand Down