我有下表:
+---------+------------+----------------+
| IRR | Price List | Cambrdige Data |
+=========+============+================+
| '1.56%' | '0' | '6/30/1989' |
+---------+------------+----------------+
| '5.17%' | '100' | '9/30/1989' |
+---------+------------+----------------+
| '4.44%' | '0' | '12/31/1990' |
+---------+------------+----------------+我正在尝试编写一个计算器,它通过进行简单的计算来更新Price List字段。逻辑基本上是这样的:
前价格*(1+内含内部收益率%)
因此,对于最后一行,计算结果为: 104.44 * (1 + 4.44%) = 100
因为我使用的是petl,所以我想弄清楚如何用上面的值和同一行中的值来更新一个字段,然后在整个Price List列中填充它。我似乎找不到一个有用的petl工具来解决这个问题。我应该手动编写一个方法吗?你们觉得怎么样?
发布于 2019-05-14 22:23:56
试试这个:
# conversion can access other values from the same row
table = etl.convert(table, 'Price List',
lambda row: 100 * (1 + row.IRR),
pass_row=True)https://stackoverflow.com/questions/50743227
复制相似问题