I have two dataframes: one with a single column(A) and another with two columns(B). I want to compare data frame A with a column of dataframe B (A contains the same type of data as the column in B and some of the rows overlap). Then I want to keep the rows of dataframe B that are overlapping.
Example:
A = pd.DataFrame([['Smile1'], ['Smile4'], ['Smile6']], columns=['Smiles'])
B = pd.DataFrame([[24, 'Smile1'], [33, 'Smile2'], [2, 'Smile3'],
[85, 'Smile4'], [68, 'Smile5'], [102, 'Smile6']], columns=['ID', 'Smiles'])
In this example I would like to keep Smile1, 4 and 6 and their IDs, preferably create a new dataframe that contains those columns, like this:
C = pd.DataFrame([[24, 'Smile1'], [85, 'Smile4'], [102, 'Smile6']], columns=['ID', 'Smiles'])
My actual data frames are much bigger.
Thank you for your time!