After rwc=range(0,len(arr))
you have len(rwc)=len(arr)
, so in the line rwc = rwc[:i-1]+rwc[i+1:]
you expect that i
is the same index for rwc
and arr
.
However after you do rwc = rwc[:i-1]+rwc[i+1:]
you get a list of smaller length (len(rwc) = len(arr) -2
), so during next iteration you start removing wrong elements from your list.
Also I suspect that you intended to do rwc = rwc[:i]+rwc[i+1:]
, which is another bug
As far as I understand you tried to do something like this:
X=arr[index[indexkey]]
Y=arr[index[secondIndexKey]]
temparr1 = []
temparr2 = []
for i in range(len(X)): #I assume len(X)=len(Y)
if not (isnan(X[i]) or isnan(Y[i])):
temparr1.append(X[i])
temparr2.append(Y[i])