Python으로 재무제표 분석하기
Rohan Chatterjee
Risk Modeler
pandas DataFrame balance_sheet에 로드되었습니다.
print(balance_sheet.head())

balance_sheet["current_ratio"] = balance_sheet["Total Current Assets"] /
balance_sheet["Total Current Liabilities"]
print(balance_sheet.head())

balance_sheet.groupby("comp_type")["current_ratio"].mean()

balance_sheet.groupby(["Year","comp_type"])["current_ratio"].mean()

.groupby() 후 .transform()을 사용하면 각 행이 속한 그룹의 결과를 행에 추가할 수 있습니다.balance_sheet["industry_curr_ratio"] =
balance_sheet.groupby([
"Year","comp_type"])["current_ratio"].transform("mean")
print(balance_sheet.head())

balance_sheet["relative_diff"] =
(balance_sheet["current_ratio"] /
balance_sheet["industry_curr_ratio"]) - 1

.isin()은 분석을 위한 하위 집합을 선택할 때 사용합니다.fmcg와 tech 기업만 필터링:fmcg_2019 = balance_sheet.loc[
(balance_sheet["Year"].isin([2019,2020])) &
(balance_sheet["comp_type"].isin(["tech","fmcg"]))
]
Python으로 재무제표 분석하기