We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09d10d2 commit 75db71cCopy full SHA for 75db71c
pandas/_libs/parsers.pyx
@@ -1099,6 +1099,16 @@ cdef class TextReader:
1099
stacklevel=find_stack_level()
1100
)
1101
1102
+ # Re-convert failed columns to their target dtype now that bad rows
1103
+ # have been removed. All remaining values should be convertible.
1104
+ for col_idx, target_dtype in failed_columns_dtypes.items():
1105
+ try:
1106
+ results[col_idx] = np.array(results[col_idx]).astype(target_dtype)
1107
+ except (ValueError, TypeError, OverflowError):
1108
+ # If conversion still fails, keep as string (shouldn't happen
1109
+ # if _identify_bad_rows worked correctly, but be defensive)
1110
+ pass
1111
+
1112
self.parser_start += end - start
1113
1114
return results
0 commit comments