typeerror argument rows has incorrect type (expected list got tuple )解决

错误原因说是用元组行调用DataFrame构造函数会引发一个错误

sql_fw = "SELECT * from table"
results = cursor.execute(sql_fw)
results = cursor.fetchall()
data1 = pd.DataFrame(results,columns=["companycode"], dtype=object)

上述用mysql调用的时候就会报错。改成下面的就行

 

results = cursor.execute(sql_fw)
results = cursor.fetchall()
lrows = []
for row in results:
    lrows.append(list(row))
data1 = pd.DataFrame(lrows,columns=["companycode"], dtype=object)

 

你可能感兴趣的:(typeerror argument rows has incorrect type (expected list got tuple )解决)