I am trying to speed up my code. The biggest problem is a few nested loops I have (they have to iterate over 25000 cells). However, when I try to get rid of these nested loops, I get a different result and I don't seem to get why.
This is one of the nested loop:
for i in range(N):
for j in range(N):
# value added in sector i (month k+1)
VA[i,k+1]= VA[i,k+1] - IO[j,i]*(Produc[i,k+1]/Produc[i,0])
This is what I did to get rid of the inner loop:
for in range(N):
VA[i,k+1]=VA[i,k+1] - np.sum(IO[:,i])*(Produc[i,k+1]/Produc[i,0])
Thank you for very much your help.