Return dataframe subset based on a list of boolean values
You can use masking here:
df[np.array([0,1,0,0,1,1,0,0,0,1],dtype=bool)]
So we construct a boolean array with true and false. Every place where the array is True is a row we select.
Mind that we do not filter inplace. In order to retrieve the result, you have to assign the result to an (optionally different) variable:
df2 = df[np.array([0,1,0,0,1,1,0,0,0,1],dtype=bool)]
Convert the list to a boolean array and then use boolean indexing:
df = pd.DataFrame(np.random.randint(10, size=(10, 3)))
df[np.array(lst).astype(bool)]
Out:
0 1 2
1 8 6 3
4 2 7 3
5 7 2 3
9 1 3 4