Let’s suppose I have two lists:
l1 = np.zeros(5,bool)
l2 = np.zeros (5,bool)
l1[3] = True
l2[1] = True
Output:
[False False False True False]
[False True False False False]
And based on these lists I want a single list which has indexes set to true based on the index of Trues (one or more) in a number of lists. All the lists have the same length and the target list must have the same length as well. What could be the pythonic way to do that so that I may get the desired list:
List 3: Desired Output:
[False True False True False]
>Solution :
If what I understand is that you want to apply an or operator between vectors, this would be the way to develop it:
import numpy as np
l1 = np.zeros(5,bool)
l2 = np.zeros (5,bool)
l1[3] = True
l2[1] = True
l_full = np.logical_or(l1,l2)
l_full
# array([False, True, False, True, False])