I have two dataframes as follows:
df1:
| col1 | col2 |
|---|---|
| ABC | 1 |
| def | 22 |
| def | 32 |
| aac | 53 |
| ddf | 53 |
| tefg | 53 |
df2:
| col1 |
|---|
| ABC |
| def |
| aac |
| ddf |
| tefg |
Now I want to retain rows in df1, such that value of column "col1" in df1, is present in df2 "col2"
Is there a simple straightforward way to achieve it in Python?
Currently, I am doing it in a brute way with 2 nested for loops, but it is computationally intensive.