I need to compare two datasets:
DF1
Subj 1 2 3
0 Biotech Cell culture Bioinfo Immunology
1 Zoology Cell culture Immunology NaN
2 Math Trigonometry Algebra NaN
3 Microbio Biotech NaN NaN
4 Physics Optics NaN NaN
DF2
Subj 1 2
0 Biotech Bioinfo Immunology
1 Zoology Immunology Botany
2 Microbio NaN NaN
3 Physics Optics Quantumphy
4 Math Trigonometry NaN
How I want my result dataframe:
Subj 1 2
0 Biotech Bioinfo Immunology
1 Zoology Immunology NaN
2 Math Trigonometry NaN
3 Physics Optics NaN
I can't check row by row as the datasets are huge. The number of columns varies for both datasets, but rows are the same in number. Since the order of the row elements also vary, I can't simply use merge(). I tried compare function, but it either removes all common elements or forms a dataframe containing both. I can't seem to pick out just the common elements.