I have the following data frame which I want to apply bfill as follows:
'amount' | 'percentage' |
---|---|
Nan | |
1.0 | 20 |
2.0 | 10 |
Nan | |
Nan | |
Nan | |
Nan | |
3.0 | 50 |
4.0 | 10 |
Nan | |
5.0 | 10 |
I want to bfill Nan in the amount column as per percentage in the percentage column i.e., if the corresponding percentage is 50 then fill 50% of Nan before the number (partial fill). e.g. amount with 3.0 value have a percentage of 50 so out of 4 Nan entries, only 50% are to be bfill.
proposed output:
'amount' | 'percentage' |
---|---|
Nan | |
1.0 | 20 |
2.0 | 10 |
Nan | |
Nan | |
3.0 | |
3.0 | |
3.0 | 50 |
4.0 | 10 |
Nan | |
5.0 | 10 |
Please help.