I have a dataframe like below:
Col1 Col2
1 5
2 6
3 6
I want to write a while loop that will find the minimum sum, add 1 for that row in a new column until that new column sum is 5. Every time a row has a min, add 1.
For example:
Col1 Col2 Col1&Col2_sum New_Value
1 5 6 1
2 6 8 0
3 6 9 0
Now add 5 to column to col1 for the first row since 6 was the minimum.
Col1 Col2 Col1&Col2_sum New_Value
6 5 11 1
2 6 8 1
3 6 9 0
Now Add 5 to the 2nd since 8 was the minimum.
Col1 Col2 Col1&Col2_sum New_Value
6 5 11 1
7 6 13 1
3 6 9 1
Now Add 5 to the 3rd since 9 was the minimum.
Col1 Col2 Col1&Col2_sum New_Value
6 5 11 2
7 6 13 1
8 6 14 1
Now Add 5 to the 1st since 11 was the minimum. (Final output)
Col1 Col2 Col1&Col2_sum New_Value
11 5 16 2
7 6 13 2
8 6 14 1