-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
Closed
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsIO SQLto_sql, read_sql, read_sql_queryto_sql, read_sql, read_sql_query
Milestone
Description
to_sql uses iterrows which leads to data conversion, and in the case of mixed data types, can lead to data loss.
s1 = pd.Series([0],dtype=np.float32)
s2 = pd.Series([2**27 + 1],dtype=np.int32)
df = pd.DataFrame({'float':s1, 'int':s2})
for row in df.iterrows():
print row[1][1] - (2**27 + 1)(The same issue applies when using df.to_sql)
I found the same bug in to_stata and have submitted a PR on it.
to_sql is the only other location in pandas the uses iterrows, which should probably be avoided in all non-user code.
It should be an easy fix using something like itertuple - I don't use the SQL code so I'm not in a good position to fix this problem.
Metadata
Metadata
Assignees
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsIO SQLto_sql, read_sql, read_sql_queryto_sql, read_sql, read_sql_query