NumPy supports boolean indexing
a[f]
This assumes that a
and f
are NumPy arrays rather than Python lists (as in the question). You can convert with f = np.array(f)
.
NumPy supports boolean indexing
a[f]
This assumes that a
and f
are NumPy arrays rather than Python lists (as in the question). You can convert with f = np.array(f)
.