I have the df shown below where data is used for an exercise on virus spreading.
df1
Node Target Node_Label Target_Label
A B 1 0
B A 0 1
C A 1 1
C D 1 1
I need to remove the labels of Node/Target based on the column Selected in the df below:
Node Label Selected
A 1 True
B 0 False
C 1 True
D 1 False
E 0 False
F 1 False
G -1 True
The expected output therefore would be
Node Target Node_Label Target_Label
A B 0
B A 0
C A
C D 1
How can I remove the labels in df1 based on the Selected values in df2? Would a filter condition where I check the condition of Selected in df2 and apply it in df1 good in this case?