簡體   English   中英

如何計算python pandas中的滾動IRR

[英]How to calculate a rolling IRR in python pandas

我有兩列的數據框:CFs 和 NAV,(現金流和凈資產估值)現在想要計算滾動 IRR。 歡迎任何建議。

示例:CFs NAV -100 100 1 101 2 103 3 106 2 108 110 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM