Question about dataframe manipulations. not HW, although I will phrase it as a HW problem. I know there is a 3 line way of doing this but I can't seem to find it.
Problem
I have a dataframe A with 10 columns and a thousand rows, it's filled with some data. I have a 1-column matrix B with 1 column and a thousand rows, it's filled by 1 and 0 (TRUE or FALSE).
Goal: create a new dataframe C that contains only the rows in A that had a TRUE value in the equivalent index of matrix C.
(More clarification in case its not clear) I performed operations on A, stored the result (true or false) in a column dataframe (of same length of course) and now wish to extract that into its own matrix.
The size of the new matrix is sum(B) X 10 (just a logical deduction)
Thank you for reading! Your help is appreciated.
Example
Dataframe A
Name State metric1 metric2
Joe MA 23 25
Moe AZ 123 2971
Bo CA 938 387
Yo UT 1 3
matrix B
1
0
1
0
Desired Output (dataframe C)
Name State metric1 metric2
Joe MA 23 25
Bo CA 938 387