合併財務報表
你剛學會將 JSON 資料讀入 Python,並從現金流量表計算兩個比率。要計算現金流量與淨利比(cash flow to net income ratio)以及營業活動現金流量比率(operating cash flow ratio),不只需要公司的現金流量表,還需要損益表與資產負債表的資訊。
在這個練習中,你將練習使用 pandas 把 JSON 資料載入 Python,並將其與損益表與資產負債表資料合併。
pandas 已替你以 pd 載入。含有資產負債表與損益表資訊的資料集分別為 balance_sheet 與 income_statement,也都已經載入完成。
本練習屬於課程
使用 Python 分析財務報表
練習說明
- 先將
cash_flow_tech.json讀成一個 pandas DataFrame。 - 將損益表與資產負債表資料合併,結果命名為
merged_income_statement_balance_sheet;以"Year"與"company"作為連接用的欄位。 - 將現金流量資料與
merged_income_statement_balance_sheet合併。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Read cash flow data
cash_flow = ____
# Merge income statement data with balance sheet data
____ = pd.____(income_statement, ____, on=____)
# Now merge it with cash flow data
merged_all = pd.____(cash_flow, ____, on=____)