Анализ финансовой отчётности на Python
Rohan Chatterjee
Risk Modeler
pandas с именем balance_sheet.
----CODE_GLUE----
```print(balance_sheet.head())
----CODE_GLUE----
`

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()

.transform() применяется после .groupby(): добавляет результат группировки к каждой строке в соответствии с её группой.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 за 2019 и 2020 годы:fmcg_2019 = balance_sheet.loc[
(balance_sheet["Year"].isin([2019,2020])) &
(balance_sheet["comp_type"].isin(["tech","fmcg"]))
]
Анализ финансовой отчётности на Python