Imagine we have the following 2 pandas tables:
employee_id country
1 Sweden
2 Denmark
....
45 Germany
In another table I have the employee_id and want to create a new column where the country for the employee_ID is matched from the other table. Note that in this table the same employee_id can occur throughout multiple rows.
employee_id year salary
1 2017 45000
2 2017 50000
1 2018 46000
....
How do I create the extra column on the last table using the information from the first table?
I was trying a code like:
df.loc[df.isin(df1.employee_id), 'country'] = df1.loc[df1.employee_id.isin(df.id), 'country']
However that did not work.