My data frame looks like this:
BookValue  Maturity   Yield   Weight
       20      2018   4.000  0.00282
       30      2019   4.550  0.00424
       70      2026   1.438  0.00989
       80      2026   1.438  0.01131
       60      2043   0.000  0.00848
       40      2043   0.000  0.00565
I want to calculate the sum of the total book values of all years by reducing in every step one year in order to get the following output:
Year       Book Value
2018-2043         300 
2019-2043         280
2026-2043         250
2043              100
How is it possible and is it possible without a for-loop?
 
     
     
    