Skip to content

Commit fc10a5f

Browse files
committed
fix: try other dtypes instead of skipping to float64
1 parent be21b2e commit fc10a5f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

pandas/_libs/parsers.pyx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,21 +1070,18 @@ cdef class TextReader:
10701070
return self._string_convert(i, start, end, na_filter, na_hashset)
10711071
else:
10721072
col_res = None
1073+
maybe_int = True
10731074
for dt in self.dtype_cast_order:
1075+
if not maybe_int and dt.kind in "iu":
1076+
continue
1077+
10741078
try:
10751079
col_res, na_count = self._convert_with_dtype(
10761080
dt, i, start, end, na_filter, 0, na_hashset, na_fset)
10771081
except ValueError as e:
10781082
if str(e) == "Number is float":
1079-
try:
1080-
col_res, na_count = self._convert_with_dtype(
1081-
np.dtype("float64"), i, start, end, 0,
1082-
0, na_hashset, na_fset)
1083-
except ValueError:
1084-
col_res, na_count = self._convert_with_dtype(
1085-
np.dtype("object"), i, start, end, 0,
1086-
0, na_hashset, na_fset)
1087-
1083+
maybe_int = False
1084+
continue
10881085
else:
10891086
# This error is raised from trying to convert to uint64,
10901087
# and we discover that we cannot convert to any numerical

0 commit comments

Comments
 (0)