How can I use boolean array as index to filter a list?
>>> l = ['a','b','c'] >>> b = [True,False,False] >>> l[b]
The result should be:
I know numpy support it but want to know how to solve in Python.
>>> import numpy as np >>> l = np.array(['a','b','c']) >>> b = np.array([True,False,False]) >>> l[b] array(['a'], dtype='|S1')