Аналіз фінансової звітності в 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