업종별 비율 계산
이번 연습에서는 Tech와 FMCG 기업의 유동비율(current ratio)과 부채비율(debt-to-equity ratio)이 평균적으로, 그리고 시간에 따라 어떻게 다른지 살펴보겠습니다.
업종의 비율을 평균으로 보면 해당 업종의 전반적인 재무 상태를 파악할 수 있어요. 반면, 업종의 비율을 시간에 따라 보면 추세를 이해할 수 있습니다. 시간이 지나도 비율이 비교적 안정적인가요, 아니면 변동이 큰가요? 개선되고 있나요, 악화되고 있나요?
balance_sheet는 이미 pandas DataFrame으로 로드되어 있어요. 유동비율은 curr_ratio 열에, 부채비율은 debt_to_equity 열에 제공됩니다. pandas는 pd라는 별칭으로 불러왔어요.
이 연습은 강의의 일부입니다
Python으로 재무제표 분석하기
연습 안내
comp_type열이tech또는fmcg인 기업만 선택하세요..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)