I have two dataframes, the first is this one, created with the following code:
values_to_repeat = [0.33, 0.28, 0.18]
df1 = pd.DataFrame({'values_to_repeat':values_to_repeat})
The second one is the following:
values_to_call = [0,1,2,0,0,0]
df2 = pd.DataFrame({'values_to_call':values_to_call})
What I need to do is to add a column to the second data frame that contains lists of values taken from the first data frame. I will show it and then explain it with words:
The lists should contain the first value of the column "values_to_repeat" repeated for the value of "values_to_call", and then in the following 2 rows, it should take the second and the third value, until disappearing in row = (i + 3).
Explaining it row by row:
1) there is an empty list because there is a 0 in "value_to_call"
2) there is [0.33] because there is a 1 in "values_to_call"
3) there is the list [0.28, 0.33, 0.33] where the first value is the value of row number 2 that decreased to 0.28 and then 2 new 0.33 because there is a 2 in "values_to_call"
4) there is the list [0.18, 0.28, 0.28] where the first value is the value of row number 2 that decreased to 0.18 and the other 2 values are the values generated in row number 3 that decreased to 0.28
5) there is the list [0.18, 0.18], now the value generated in row number 2, after decreasing 2 times it disappeard, while the 2 values generated in row number 3 decrease to 0.18
6) there is an empty list because after appearing in i, i+1 and i+2, at i+3 the values generated in row number 3 disappeared as well


