pandas优化双重for循环

我用pandas写了个程序,二次for循环,当dataframe很大时,效率很慢,需要优化一下,麻烦各位看看

img

好难猜