I have two data frames, one that is names of people born and their frequencies in each year (1880-2017).
name gender frequency year
Mary F 7065 1880
Anna F 2604 1880
Emma F 2003 1880
Elizabeth F 1939 1880
Minnie F 1746 1880
...
and the other is years and the total number of births (1880-2017).
birth_year Male Female Total
1880 118400 97605 216005
1881 108282 98855 207137
1882 122031 115695 237726
1883 112477 120059 232536
1884 122738 137586 260324
...
These data frames are not the same size but I want to append the columns from the second data frame to the first data frame if the birth year is the same in order to include percentage population. I want to do something like this:
for i in range(len(all_names_nat_DF)):
for j in range(len(total_births)):
if all_names_nat_DF['year'][i] == total_births['birth_year']:
all_names_nat_DF.append(total_births['birth_year'][j])
But with this I get the error ValueError: Can only compare identically-labeled Series objects