Reputation: 47
ValueError: Column names of incoming data don't match column names of existing SQL table <br/>
Names in SQL table: ['id', 'variable_code', 'zcta', 'value', 'Year']
Names from incoming data: ['variable_code', 'zcta', 'value', 'Year']
The problem is the 'id'
column in SQL table. It will automatically increment. If I read csv
to DataFrame df
, then use df.to_sql()
, it will not get this error. But the speed is super low. I can also add 'id'
column to csv
file, but I need to read csv
file to DataFrame, then add id
column, and then save it to csv
file. Is there a simple way to solve this problem?
Another problem is: I have some nan
, inf
and -inf
in 'value'
column. If I use odo
, I get the following error: Unknown column 'nan' in 'field list'
. How can I fix this problem?
Upvotes: 1
Views: 153