開始使用免費開始

依產業計算比率

在這個練習中,你要評估科技(Tech)與快速消費品(FMCG)公司的流動比率與負債權益比的平均差異,以及它們隨時間的變化。

從「平均」來看某產業的比率,可以大致掌握該產業的整體財務狀況。另一方面,觀察某產業的比率隨「時間」的走勢,有助於你判斷其趨勢:這個比率是否相對穩定,或是隨時間波動?是在改善還是惡化?

balance_sheet 已為你載入為一個 pandas 的 DataFrame。流動比率在欄位 curr_ratio,負債權益比在欄位 debt_to_equitypandas 已以別名 pd 載入。

本練習屬於課程

使用 Python 分析財務報表

檢視課程

練習說明

  • 篩選欄位 comp_typetechfmcg 的公司。
  • 使用 .groupby(),依公司類型(欄位 "comp_type")計算平均流動比率與平均負債權益比。
  • 使用 .groupby(),同時依 "comp_type""Year" 計算平均流動比率與平均負債權益比。

動手互動練習

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

# Choose the tech and fmcg companies
tech_fmcg = balance_sheet.loc[balance_sheet[____].isin(____)]

# Compute the average debt-to-equity ratio and current ratio by industry
groupby_industry = tech_fmcg.____(____)[["current_ratio", "debt_to_equity"]].____

# Compute the average debt-to-equity ratio and current ratio by industry and over time
groupby_industry_time = tech_fmcg.____(____)[["current_ratio", "debt_to_equity"]].____

print(groupby_industry)
print(groupby_industry_time)
編輯並執行程式碼