-1
tlist = [("a1", "a2","a3"),("b1", "b2","b3"),("c1", "c2","c3")]
我想要什么:追加列表
df=pd.DataFrame([["a1","a2","a3"],["b1","b2","b3"],["c1","c2","c3"]])
我可以这样做:
df2 = pd.DataFrame(tlist, columns=['col1', 'col2', 'col3'])
然而,元组的列表是从一些数据库中提取等等我有一个循环,并做它一次拉数据一块,然后追加。
最新最好的方式做到这一点?
的数据拉可高达一个十亿行,现在,它可以生长。
谢谢。
#very big table#
sql2 = "Select col1,col2,col3 from bigT"
#very big table#
try:
cursor.execute (sql2)
except cx_Oracle.DatabaseError:
print ('Failed \n'+sql2)
#need to do it in chunk as not enough memory and blow up!
while True:
tlist = cursor.fetchmany()
print(type(tlist))
print (len(tlist))
if rows == []:
break;
#I cannot get this one to work
df.append([tlist],ignore_index=True)
#I cannot get this one to work
我不明白。 – piRSquared
请澄清,这篇文章不清楚 –
请看我添加的伪代码。 – Mookayama