Jun-20-2022, 11:23 AM
hello,
my array looks like :
[[10,20,'1'],[10,50,'1'],[10,100,'1'],[10,30,'1'],[20,10,'1'],[10,60,'1'],[30,10,'1']
I would like to know how to return an array(newarr) with the following logic(here is a pseudo code):I need it to be implement as faster as possible! please help be to write it in the correct and faster way in python.(maybe using numpy,i understand that numpy is fast)
thank you
my array looks like :
[[10,20,'1'],[10,50,'1'],[10,100,'1'],[10,30,'1'],[20,10,'1'],[10,60,'1'],[30,10,'1']
I would like to know how to return an array(newarr) with the following logic(here is a pseudo code):I need it to be implement as faster as possible! please help be to write it in the correct and faster way in python.(maybe using numpy,i understand that numpy is fast)
i=0 for x in arraynumpy i=i+1 for y in arraynumpy[0:i-1] if x[0]==y[1] and x[1]==y[0] and x[2]==y[2] newarr.append(x) continue; # break the loop for y,if foundthe array that will be returned for the input ,will be: [[20,10,'1'],[30,10,'1']]
thank you