Oct-08-2018, 09:34 PM
Hi all,
I am trying to find a better way to create a Boolean Mask based on certain conditions. Here is the question and my way to answer it.
Question:
l = ["a","b","a","c"], "a" is a qualified data for the future use. Create a list with boolean values.
L = [True,False,True,False]
Thanks!
I am trying to find a better way to create a Boolean Mask based on certain conditions. Here is the question and my way to answer it.
Question:
l = ["a","b","a","c"], "a" is a qualified data for the future use. Create a list with boolean values.
l = ["a","b","a","c"] L = [] for i in l: if i == "a": L.append(True) else: L.append(False)Result:
L = [True,False,True,False]
Thanks!