Reputation: 31
So I have 4 dataframes that I am attempting to loop over.
I have created a list using the following code :
list = [df1,df2,df3,df4]
After that I would like to write them to an SQL Server using :
for i in list:
i.to_sql(i,engine)
However this leads to the following error
'DataFrame' objects are mutable, thus they cannot be hashed
Any suggestions what I should be looking for?
Thanks in advance!
Upvotes: 0
Views: 67
Reputation: 611
Use the itertuples method in pandas:
for i in dataframeList.itertuples():
print i
Upvotes: 0
Reputation: 82765
You need to give the SQL table
name in the first parameter
Ex:
l = [df1,df2,df3,df4]
for i in l:
i.to_sql('TABLE_NAME',con=engine)
Upvotes: 1