I have a specific integer value k and I want to find matching values in a column of a 2d numpy array (using a "for" loop).
I thought I could use an if statement and directly compare the single array element with the integer value k.
Here is my code:
for i in range(mock.shape[0]):
n_cl = int(mock[i,0]/3500.)
zcl = mock[i,5]
pick = [np.random.random_integers(200, size=(n_cl))]
print pick[0]
if(zcl <= 0.05):
for k in range(len(pick)) :
for j in range(z_001.shape[0]):
n = z_001[j,1]
if (int(n) == pick[k]):
binaries[j,7] = mock[i,0]
binaries[j,8] = mock[i,1]
binaries[j,9] = mock[i,2]
binaries[j,10] = mock[i,3]
binaries[j,11] = mock[i,4]
I always get a ValueError about the truth value of an array with more than one element, which is ambiguous. I understand that the problem is in " int(n) == k", but I wonder where am I wrong, and how could I put things better and make this part of my code work.
idefined?nandkare arrays, not simple numbers. Check out this piece of code, that raises the same error:if (array([1,1])==array([1,3])): print 'foo'pick,i,binaries,mock, etc. all are. You'll get much more help if you can get closer to a minimal working example.