I want to delete a row from one dataset (df1) whenever in column "A" of that row is a string that is not part of any row from another dataset (df2), for example:
df1: df2:
A B A B
h 1 j 5
i 2 h 3
j 6 p 3
g 2 t 1
In this case, by analysing only column A of df2, as "j" and "h" exist in df1, these rows remain in df2. However, there is no "p" or "t" in the df1 list, so I would like these lines to be deleted from the df2 dataset.
I tried to create a loop for this goal, however, as I acceded to the indices of each row (0, 1, 2, 3 ..) and since I already had to erase other rows for other reasons, many indexes have been lost, so it starts for example in 120, then it goes do 127 and so on...
Can anyone help me in any way? Thank you very much in advance!