I want to create a pandas dataframe df1 with specific column name from a column col of another dataframe df and do a merge with another dataframe df2.
df
    Name   House
0   John   London
1   John   London
2   John   London
3   Tom    New York
4   Tom    New York
df2
     Col  Val
0    Tom    3
1    John   2
2    Alex   5
3    Sarah  2
This what I am doing
import pandas as pd
x = pd.unique(df['Name'])
x = pd.DataFrame(x)
x.columns = ['col']
df1 = pd.merge(x, df2, on = 'Col')
df1
    Col  Val 
0   Tom    3
1   John   2
 
     
    