原文以及建議書請看此篇:
香港保單富衛人壽(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: 如何使用 os.environ[“PATH”] 設定環境變數?與 sys.path.append() 差別為何? Python: 如何使用 os.environ[“PATH”] 設定環境變數?與 sys.path.append() 差別為何?](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2024/09/20240905135312_0_890fa1.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

![Python Pandas GroupBy 的 size 陷阱:為什麼你的計數結果總是不對?如何計算重複次數? duplicates = df.duplicated( subset = [‘name’] ) Python Pandas GroupBy 的 size 陷阱:為什麼你的計數結果總是不對?如何計算重複次數? duplicates = df.duplicated( subset = [‘name’] )](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/06/20250609143758_0_53821c.png?quality=90&zoom=2&ssl=1&resize=350%2C233)
![Python: pandas.Series如何只保留str,去除重複值?#isinstance(x:Any, str) -> bool #.drop_duplicates() #Series.apply( function )逐元素應用function運算 #DataFrame.apply( function )逐Series應用function運算 .drop_duplicates() 跟.unique()有何差別? df.drop_duplicates() 等效於 df[~df.duplicated()] Python: pandas.Series如何只保留str,去除重複值?#isinstance(x:Any, str) -> bool #.drop_duplicates() #Series.apply( function )逐元素應用function運算 #DataFrame.apply( function )逐Series應用function運算 .drop_duplicates() 跟.unique()有何差別? df.drop_duplicates() 等效於 df[~df.duplicated()]](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2024/11/20241123194900_0_5218de.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

![Python: list.index() 只能找到第一個元素的index,若元素有重複,如何找出所有index? indexes = [index for index, value in enumerate(my_list) if value == target] Python: list.index() 只能找到第一個元素的index,若元素有重複,如何找出所有index? indexes = [index for index, value in enumerate(my_list) if value == target]](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2024/10/20241010101216_0_12b6c0.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




近期留言