I have two separate dataframes df1 and df2, both dataframes contain an id column which links rows between them. df2 has a group column that df1 does not contain. What I would like to do is go through each id in df1 and check to see if it is in df2 then if it is to take the group column value and put it in df1 under a new column of the same name. Would it be easiest to write a function to loop through or is there a pandas trick I could utilize here?

pandas.merge(df1, df2, how='outer', on=['id'])