When a DataFrame ("Given_DF") has a Boolean variable (such as B below),how can one subset the DataFrame to keep only rows of Variable B with True value?.
Given_DF
ID A B
0 123 True
1 456 False
2 789 False
3 132 True
4 465 False
The 'Desired' subset is the DataFrame with only two rows (with ID 0 and 3).
Tried subsetting B as a column,
Desired = Given_DF["B"].isin(True)Tried indexing the variable B and using loc to subset to "True" incidences B.
prep.sort_index(level=["B"]) Desired = prep.loc["True"]
Neither attempts worked. Help would be appreciated.