Tesla 損益表
Tesla 損益表的資料集名為 income_statement。
這個資料集有一個最後一欄叫做 Trailing Twelve Months(TTM),代表最近 12 個月可用的資料。我們會用它來計算 2018 年的 Tesla 預測。
我們只關心 'Revenue'、'Gross profit'、'Total operating expenses' 和 'Net income' 這幾列,因此會先建立一個過濾後的損益表,只顯示這些列。過濾的程式碼模式如下:
dataframe[dataframe.columnname.isin(list_of_categories)]
本練習屬於課程
使用 Python 進行財務預測
練習說明
- 在終端機中查看
income_statement。 - 建立一個名為
interesting_metrics的清單,包含我們感興趣的列。 - 使用
.isin()方法,篩選出metric位於interesting_metrics的損益表列。 - 檢視結果。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Choose some interesting metrics
interesting_metrics = ['____', '____', '____', '____']
# Filter for rows containing these metrics
filtered_income_statement = income_statement[income_statement.____.____(____)]
# See the result
print(filtered_income_statement)