-1

我有两列的数据框:CF 和 NAV,(现金流和净资产估值)现在想要计算滚动 IRR。欢迎任何建议。

示例:CF 资产净值 -100 100 1 101 2 103 3 106 2 108 110 0

在此处输入图像描述

4

1 回答 1

0

IIUC,用于expanding申请irr

Python env: pip install numpy-financial
Anaconda env: conda install -c conda-forge numpy-financial

import numpy_financial as npf

df['IRR'] = df['CFs'].expanding(1).agg(npf.irr)

输出:

>>> df
   CFs   NAV       IRR
0 -100   100       NaN
1    1   101 -0.990000
2    2   103 -0.853490
3    3   106 -0.664270
4    2   108 -0.558468
5  110     0  0.034784
于 2021-10-22T07:33:52.647 回答