I have to dataframes (df), df1 contains countries with the number infections over time (2000+ rows) and df2 contains countries with population numbers (200 rows).
I have been trying to get the population number from df2 to df1 in order to transform the infections to infection density (?) over time.
In my mind I have to iterate over the rows of df1 and check the Country column per index to df2. If the result is True I can copy the the population from df2 to df1. I have tried multiple approaches (just one below) but am at a loss right now :(...could someone give me a push in the right direction?
for index, row in df2.iterrows():
df_test = df1['Country'].str.contains(row[0])
Edit update with df1, df2 and preferred outcome: df1
ObservationDate Country/Region Confirmed
0 -2.118978 Hong Kong 0.0
1 -2.118978 Japan 2.0
2 -2.118978 Macau 1.0
3 -2.118978 Mainland China 547.0
4 -2.118978 South Korea 1.0
df2
0 1
0 China 1.401580e+09
1 India 1.359321e+09
2 United States[c] 3.293798e+08
3 Indonesia 2.669119e+08
4 Brazil 2.111999e+08
df_preferred
ObservationDate Country/Region Confirmed Population
0 -2.118978 Hong Kong 0.0
1 -2.118978 Japan 2.0
2 -2.118978 Macau 1.0
3 -2.118978 Mainland China 547.0 1.401580e+09
4 -2.118978 South Korea 1.0
merge.