Compute ratios by industry
In this exercise, you will assess how the current ratio and debt-to-equity ratio of Tech and FMCG companies are different on average and over time.
An industry's ratio, on average gives us an overall idea of the industry's financial condition. On the other hand, an industry's ratio over timehelps us understand its trends: is the ratio relatively stable or fluctuating over time? Is it improving or worsening?
balance_sheet has been loaded for you as a pandas DataFrame. The current ratio is provided in a column called curr_ratio, and the debt-to-equity ratio is provided in a column called debt_to_equity. pandas has been loaded with the alias pd.
Questo esercizio fa parte del corso
Analyzing Financial Statements in Python
Istruzioni dell'esercizio
- Select those companies whose column
comp_typeistechorfmcg. - Use
.groupby()to compute the average current ratio and debt-to-equity ratio grouped by company type (denoted by the column"comp_type"). - Use
.groupby()to compute the average current ratio and debt-to-equity ratio by both"comp_type"and"Year".
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# 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)