Forecasting profit for Tesla
As in the previous exercise, the dataset for the Tesla income statement is named income_statement
.
Using what we have learned in the previous exercise, we will now append a new column with 2018 Forecast data, which we will assign the header "Forecast".
For this exercise, we would like to set the filtered_income_statement
to only show the row 'Revenue'.
Remember, the TTM column is the most recent 12-month value that we will use for the 2018 forecast. Thus far, we have the following information for 2018:
- The market demand analysis predicts the revenue to increase to 13,000 in 2018 due to increased sales of Model 3.
This exercise is part of the course
Financial Forecasting in Python
Exercise instructions
- Create a filtered income statement only for the
revenue_metric
row. - Get the number of columns of
filtered_income_statement
, using the length (len()
) of thecolumns
attribute. - Insert a new column in
filtered_income_statement
.- Locate it at the end of the row (use
n_cols
as theloc
ation). - Use
'Forecast'
as the column name. - Insert the value
13000
.
- Locate it at the end of the row (use
- Print the result.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
revenue_metric = ['Revenue']
# Filter for rows containing the revenue metric
filtered_income_statement = ____[____.____.____(____)]
# Get the number of columns in filtered_income_statement
n_cols = ____(filtered_income_statement.____)
# Insert a column in the correct position containing the column 'Forecast'
filtered_income_statement.insert(____, '____', ___)
# See the result
print(filtered_income_statement)