mercredi 27 avril 2016

Column vector with for loop and if statement - IndexError: too many indices for array

I am trying to create a binary column vector (y3) based on a comparison of two lists. For each element of both list, if one is bigger than the other, 0, if not ,1. The result (ones and zeroes) being stored in y3.

t=5
list1 = data[:t,0]  # Extrated from data = np.array(list(...
list2 = data[:t,1]  # Same
for i in range(t):
    if list1[i]<=list2[i]:
        y3[i]=0
    else:
        y3[i]=1

I get an "IndexError: too many indices for array". What is wrong with the code? Thank you for your valuable help.

Aucun commentaire:

Enregistrer un commentaire