開始使用免費開始

依產業計算相對差

比較公司比率與產業平均的相對差,是判斷公司是否與同業水準相當的好方法。在本練習中,你要計算多家民生消費品(FMCG)公司的權益乘數比相對於產業平均的相對差。

已為你載入一個 pandas 的 DataFrame balance_sheetpandas 也已以別名 pd 載入。你可以在主控台呼叫 balance_sheet.columns,查看本練習可用的欄位。

本練習屬於課程

使用 Python 分析財務報表

檢視課程

練習說明

  • 篩選 balance_sheet,只保留在 balance_sheet"comp_type" 欄位中標記為 fmcg 的公司。
  • fmcg 新增一個欄位,計算權益乘數比。
  • fmcg 新增一個欄位,計算每年的平均權益乘數比。
  • fmcg 新增一個欄位,計算公司權益乘數比相對於產業平均的相對差。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Subset the fmcg companies
fmcg = balance_sheet.____[____]

# Compute equity multiplier ratio
fmcg["equity_multiplier_ratio"] = ____

# Compute average equity multiplier ratio by year
fmcg["average_equity_multiplier_ratio"] = fmcg.____(____)[____].____(____)

# Compute the relative difference
fmcg["relative_difference"] = ____

print(fmcg[["Year", "company", "relative_difference"]])
編輯並執行程式碼