My problem is to apply a multiplication factor K=0.5
starting at the first number of a set of numbers that repeats only in certain columns [Bird1 and Bird2]. This factor will be applied to the previous value calculated UNTIL the last value that repeats.
TABLE A:
Bird1 Bird2 Bird3
100 50 200
50 40 100
40 40 80
40 80 200
40 50 200
40 90 200
100 12 40
The result should be as per the table below. How to implement this code in python?
TABLE B:
Bird1 Bird2 Bird3
100 50 200
50 40 100
40 40 80
**20** 80 200
**10** 50 **100**
**5** 90 **50**
100 12 40
Using the df.interpolate()
command is not suitable because it uses all the values of the repeating lines.
I would just like a constant K
starting and being applied to the first value, and that this multiplication is repeated in the next values, until the last value of the repeating line.
One strategy I used is to use the df.ne(0)
command to compare the lines and check if they have the same value, but I'm having trouble implementing it.