使用熊猫数据帧(iterrows())逐行更新雪花 table 需要很多时间。有人可以提供更好的方法来加速更新吗?
Updating snowflake table row by row using panda dataframe (iterrows()) taking lot of time .Can some one give better approach to speed up updates?
ctx=con.cursor()
ctx.execute(select col1 from table1)
result=ctx.fetchall()
data=pd.DataFrame(result)
data.columns['field']
for index,row in data:
update table2 set col2='some value' where col1=str(row['field'])
解决方法是:
将数据插入一些瞬态 table,然后使用该 table 进行更新。
对于插入:
数据 = panda.DataFrame(结果)
只需使用 data.to_csv('file complete path',index=False,Header=True)
使用 put 命令将文件放在内部阶段,然后使用 Copy 命令将数据复制到瞬态 table.
稍后您可以使用此 table 更新您的目标 table。
ctx=con.cursor() ctx.execute(select col1 from table1) result=ctx.fetchall() data=pd.DataFrame(result) data.columns['field'] for index,row in data: update table2 set col2='some value' where col1=str(row['field'])
解决方法是:
将数据插入一些瞬态 table,然后使用该 table 进行更新。
对于插入: 数据 = panda.DataFrame(结果) 只需使用 data.to_csv('file complete path',index=False,Header=True) 使用 put 命令将文件放在内部阶段,然后使用 Copy 命令将数据复制到瞬态 table.
稍后您可以使用此 table 更新您的目标 table。