python - 净现值——Numpy 与 Excel

标签 python excel

我正在参加 Coursera 的类(class),对一个简单的 NPV 函数感到困惑。

问题:

What is the present value of $4,000 per year annuity for 8 years at an interest rate of 6%?

Excel:

=NPV(6%, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000)

=24,839 美元

Numpy_Financial:

npf.npv(0.06, [4000 for i in range(8)])

=26,329 美元

excel 答案被认为是正确的,并且在 numpy_financial NPV 函数中似乎没有任何可行的参数。有谁知道如何在 Python 中获取 excel 的值?

最佳答案

Excel假设第一个值在 t=1(没有初始财富),而 numpy-financial假定第一个值在 t=0。因此,在 numpy 中,你从 4000 的初始财富开始,你的结果基本上是 excel 结果 * 1.06。

如果要用numpy计算excel结果,将初始财富设置为零:

npf.npv(0.06, [0] + [4000 for i in range(8)])

关于python - 净现值——Numpy 与 Excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65454574/

相关文章:

python - 如何从可能为空值的列表列表中生成字典?

vba - VB 与 VBA 有什么区别?

python - 管道发送和接收。 unpack 需要长度为 4 的字符串参数

python - 如何在python中找到运行长度编码

vba - 使用公共(public)列合并两个 Excel 文件

工作表的 Excel Vba 复制方法失败

excel - 如何从 Excel 中的整数列中过滤字符串以在 Python 中处理

excel - 如何修复从 Access 内部关闭 Excel

python - 使用元组 Python 从字典创建字典

python - 执行外部 python 脚本并获取返回的输出