First of all, I am a very beginner
Iβve got the following problem :
A DataFrame named cr1 with 553 columns
Then, I make two loops as follow :
cr2=copy(cr1)
#-----------------#
#Loop on scenarios#
#-----------------#
@threads for k in 0:499
cr1=copy(cr2)
cr1[!,"scn"].=k
cr1 = leftjoin(cr1,tra,on = [:scn])
for i in 1:40
#----------------------#
##Projection on 40 years
#----------------------#
cr1[!,"ch_prime"*str(i)].=cr1[!,"ch_prime"].*(cr1[!,"coll_"*str(i)]
...job on other columns
At the beginning, I make a copy of cr1 to keep the vision of the DataFrame at this stage. Indeed I need to restart of this vision at each iteration of the k-loop.
So,
1- I collect the scenario number (=k)
2- I make a merge with another DataFrame(named tra) to collect 40 columns (tra1-tra40) different on each scenario
3- I make a projection on 40 years, adding some new columns to cr1
4- Just before the end of the loop, I would like to append a result data frame with cr1 result for k=0,2,β¦499
But it doesnβt work. Julia do some job but cr1 is not modified.
I tried adding a global on the first line of the loop and squeezing the @threads
for k in 0:499
global cr1=copy(cr2)
Then it works, but with no threading and I want to keep it for performance
Have you any idea another way to do this or a way to thread the last solution ?