I've got two dataframes. One looks like:
Year Count
1 3
2 2
3 1
4 5
5 4
The other looks like
ID Value
1 100
2 50
3 0
4 25
5 50
I'm looking to use the Count in first dataframe to loop through the second dataframe. I want to use the count value in each row to randomly select from the Value column in the second dataframe N times where N is the value in the Count column - and add these values up, giving a new column in the first dataframe thus:
Year Count RandSum
1 3 200
2 2 50
3 1 100
4 5 225
5 4 200
i.e. so the RandSum column added to the first dataframe is the sum of "Count" random selections from the Value column in the 2nd dataframe (i.e. in the first row, Count = 3, so drawing randomly from the Value column in the 2nd table drew 100, 50 and 50 = 200)
Any help appreciated for this relative python novice.