Say I have the first pandas DataFrame below:
A B ID
0 22.0 male 12
1 38.0 female 34
2 26.0 female 44
3 35.0 female 04
4 35.0 male 78
The second pandas DataFrame is:
C D ID
0 xx xx 12
2 xx xx 44
4 xx xx 78
I want the output be like:
A B ID
0 22.0 male 12
2 26.0 female 44
4 35.0 male 78
which I only want to select rows from the first DataFrame that has the same ID appeared in the second DataFrame.
What is the most efficient way to do this?