0

I have the following table:

+---------+------------+----------------+
| IRR     | Price List | Cambrdige Data |
+=========+============+================+
| '1.56%' | '0'        | '6/30/1989'    |
+---------+------------+----------------+
| '5.17%' | '100'      | '9/30/1989'    |
+---------+------------+----------------+
| '4.44%' | '0'        | '12/31/1990'   |
+---------+------------+----------------+

I'm trying to write a calculator that updates the Price List field by making a simple calculation. The logic is basically this:

previous price * ( 1 + IRR%)

So for the last row, the calculation would be: 100 * (1 + 4.44%) = 104.44

Since I'm using petl, I'm trying to figure out how to update a field with its above value and a value from the same row and then populate this across the whole Price List column. I can't seem to find a useful petl utility for this. Should I just manually write a method? What do you guys think?

1 Answers1

0

Try this:

# conversion can access other values from the same row    

    table = etl.convert(table, 'Price List',
                               lambda row: 100 * (1 + row.IRR),
                               pass_row=True)