Updating 1st dataframe columns from 2nd data frame coulmns I have two data frames df1 and df2 which look something like this.

    Name    Age    Sex
0   Sam      25     M  
1   John     22     M
2   Larry    34     M
3   Mark     32     M

    Name    Age    Sex
0   Kelvin   51     M  
1   Bob      26     M
2   Larry    37     M
3   Jerry    17     M
6   Nick     68     M
8   Sam      98     M
9   Jax      78     M
10  John     23     M
11  Mark     47     M
12  Jerry    68     M


My output should ideally be this:

    Name    Age    Sex
0   Sam      98     M  
1   John     23     M
2   Larry    37     M
3   Mark     47     M


I have tried join and merge but the columns doesn't line up
Try the below code, it should do the trick for you

df1['Age'] = df1['Name'].replace(df2.set_index('Name')['Age'].dropna())
df1['Sex'] = df1['Name'].replace(df2.set_index('Name')['Sex'].dropna())
print(df1)