原文以及建議書請看此篇:
香港保單富衛人壽(FWD)盈聚優裕(UFE1)壽險計畫IRR分析
本篇要展示使用Python撰寫的程式
(已轉為exe檔,無須python環境)
如何讀取csv逗點分隔檔
(每列內容為現金流)
計算保單的IRR
寫一個 每列內容與建議書
每年現金流 一致的csv檔:
若您不明白為何要這樣寫
請參考以下文章中的建議書:
香港保單富衛人壽(FWD)盈聚優裕(UFE1)壽險計畫IRR分析
逗點分隔檔使用記事本寫
不要用Libre Office之類的套裝軟體
因為Libre會將較短的列(現金流)
補逗點跟空值,
補到長度跟最長的列一樣
導致程式無法運算
執行結果:

輸入檔案路徑\檔名.副檔名:

除了輸出現金流狀況以外
還會計算各年的IRR:

IRR資料有輸出一個csv檔:

到小數點下2位都沒有差別
您將輸入n年度末解約金?n=?
待使用者輸入下一筆資料或-9999離開
推薦hahow線上學習python: https://igrape.net/30afN

![Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index) Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index)](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250420212553_0_6fb2c3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)
![Python: List[ pandas.Series ] 轉DataFrame技巧:正確理解row和column的關係,同 concat( List[ pandas.Series ], axis=1 ).T Python: List[ pandas.Series ] 轉DataFrame技巧:正確理解row和column的關係,同 concat( List[ pandas.Series ], axis=1 ).T](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250422150133_0_1cfa94.png?quality=90&zoom=2&ssl=1&resize=350%2C233)






![Python Logging 完全指南:從基礎到實戰應用; import logging ; logging.basicConfig(level=logging.INFO, handlers=[ logging.StreamHandler(), logging.FileHandler(‘app.log’, mode=’a’, encoding=’utf-8′)] ) ; inspect.currentframe().f_code.co_name #動態取得funcName Python Logging 完全指南:從基礎到實戰應用; import logging ; logging.basicConfig(level=logging.INFO, handlers=[ logging.StreamHandler(), logging.FileHandler(‘app.log’, mode=’a’, encoding=’utf-8′)] ) ; inspect.currentframe().f_code.co_name #動態取得funcName](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/10/20251021155823_0_c16012.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言