I have a dataframe df1, which stores the current registered course and the previous course taken.
| course | previous_course |
|---|---|
| CS201 | CS101 |
| CS201 | CS102 |
| CS201 | CS103 |
| CS202 | CS101 |
| CS202 | CS102 |
| CS202 | CS103 |
Some courses have prerequisite, which are also stored in dataframe df2 (it's one to many relationship, one course could have many prerequisite)
| course | prerequiste |
|---|---|
| CS201 | CS101 |
| CS202 | CS102 |
| CS202 | CS103 |
I would like to match if the previous_course in df1 is prerequisite or not, and create another column (1 or 0). Could you advise what should I do? Thanks a lot!