来自一个df的嵌套“ for循环”在空数据帧中追加

时间:2020-03-03 04:59:21

标签: python pandas performance join

df1 : 20 x 5000  (Dataframe)
df2:  80 x 5000 (with null variables) 

我期待在df2的特定位置附加df1,该位置基于df1中的值

Here is the meaning of image !!

例如

df1.ioc[1][1] = 5 

 df2[5][1] = 1

然后,我想出一个循环:

for i in tqdm(range(len(df)), desc='loop1'):
    for j in range(1,21):
        a = df.iloc[i][j]
        df_empty[a][i] = 1

根据tqdm,它表明循环大约需要20分钟才能完成

有人建议循环可以提高效率

0 个答案:

没有答案
相关问题