I have two arrays as follows:
e = np.array([True, False, True, True])
f = np.array([True, False, False, True])
I want to get the index i where e[i] and f[i] == True.
The expected output for the above will be:
[0,3] since e[0] == True and f[0] == True; e[3] and f[3] ==True
There may be more of such matches, so I need a list of all of the indices which satisfy the above condition.
I tried to find the list of matching values by doing this:
list(e&f)
Out[474]:
[True, False, False, True]
To get the index, I thought I could use .index(True) of list. But it doesn't work or just gives output as 0. Maybe only giving the first index and not all.
Finally, I need the 1 added to each element of output so instead of [0,3] output should be [1,4] but this is easy I can do that if I get the indices,
Aucun commentaire:
Enregistrer un commentaire