@@ -722,6 +722,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
722
722
ndarray[float64_t] floats
723
723
ndarray[complex128_t] complexes
724
724
ndarray[int64_t] ints
725
+ ndarray[uint64_t] uints
725
726
ndarray[uint8_t] bools
726
727
ndarray[int64_t] idatetimes
727
728
ndarray[int64_t] itimedeltas
@@ -731,6 +732,8 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
731
732
bint seen_datetimetz = 0
732
733
bint seen_timedelta = 0
733
734
bint seen_int = 0
735
+ bint seen_uint = 0
736
+ bint seen_sint = 0
734
737
bint seen_bool = 0
735
738
bint seen_object = 0
736
739
bint seen_null = 0
@@ -743,6 +746,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
743
746
floats = np.empty(n, dtype = ' f8' )
744
747
complexes = np.empty(n, dtype = ' c16' )
745
748
ints = np.empty(n, dtype = ' i8' )
749
+ uints = np.empty(n, dtype = ' u8' )
746
750
bools = np.empty(n, dtype = np.uint8)
747
751
748
752
if convert_datetime:
@@ -798,11 +802,21 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
798
802
floats[i] = < float64_t> val
799
803
complexes[i] = < double complex > val
800
804
if not seen_null:
801
- try :
802
- ints[i] = val
803
- except OverflowError :
805
+ seen_uint = seen_uint or (val > np.iinfo(np.int64).max)
806
+ seen_sint = seen_sint or (val < 0 )
807
+
808
+ if seen_uint and seen_sint:
804
809
seen_object = 1
805
810
break
811
+
812
+ if seen_uint:
813
+ uints[i] = val
814
+ elif seen_sint:
815
+ ints[i] = val
816
+ else :
817
+ uints[i] = val
818
+ ints[i] = val
819
+
806
820
elif util.is_complex_object(val):
807
821
complexes[i] = val
808
822
seen_complex = 1
@@ -865,7 +879,10 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
865
879
elif seen_float:
866
880
return floats
867
881
elif seen_int:
868
- return ints
882
+ if seen_uint:
883
+ return uints
884
+ else :
885
+ return ints
869
886
elif (not seen_datetime and not seen_numeric
870
887
and not seen_timedelta):
871
888
return bools.view(np.bool_)
@@ -896,7 +913,10 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
896
913
if not seen_int:
897
914
return floats
898
915
elif seen_int:
899
- return ints
916
+ if seen_uint:
917
+ return uints
918
+ else :
919
+ return ints
900
920
elif (not seen_datetime and not seen_numeric
901
921
and not seen_timedelta):
902
922
return bools.view(np.bool_)
0 commit comments