Yes, you can use groupby to remove your duplicate lines. Do everything you’ve done to define left and right. Now, I define a new dataframe on your last line:
left2=left.merge( right, how='left', on='age' )
df= left2.groupby(['age'])['salary'].first().reset_index()
df
At first I used a .min(), which will give you the minimum salary at each age, as such:
df= left2.groupby(['age'])['salary'].min().reset_index()
But you were specifically asking about the first match. To do so you use the .first() option. Note: The .reset_index() at the end, just reformats the output of the groupby to be a dataframe again.