อัตราส่วนจากงบกำไรขาดทุนและงบดุล

การวิเคราะห์งบการเงินด้วย Python

Rohan Chatterjee

Risk modeler

อัตราส่วนหมุนเวียนสินทรัพย์

  • อัตราส่วนของรายได้ต่อสินทรัพย์
  • วัดประสิทธิภาพการใช้สินทรัพย์ของบริษัทเพื่อสร้างรายได้

สูตร:

$$\dfrac{\text{Total Revenue}}{\text{Total Assets}}$$

การวิเคราะห์งบการเงินด้วย Python

คำนวณอัตราส่วนหมุนเวียนสินทรัพย์ด้วย pandas

merged_dat = pd.merge(income_statement, balance_sheet, on = ["Year", "company"])
  • merged_dat สามารถใช้คำนวณอัตราส่วนและเพิ่มเป็นคอลัมน์ใหม่ใน DataFrame ได้
merged_dat["asset_turnover"] = merged_dat["Total Revenue"] / merged_dat["Total Assets"]
การวิเคราะห์งบการเงินด้วย Python

ฟังก์ชันที่กำหนดเองสำหรับคำนวณอัตราส่วน

  • การสร้างคอลัมน์เหล่านี้ซ้ำๆ ทำให้โค้ดยาวและซ้ำซ้อน
balance_sheet["current_ratio"] = balance_sheet["Total Current Assets"] / balance_sheet["Total Current Liabilities"]

balance_sheet["debt_to_equity"] = balance_sheet["Total Liab"] / balance_sheet["Total Stockholder Equity"]
  • เพื่อหลีกเลี่ยงการพิมพ์โค้ดซ้ำ สามารถรวมไว้ในฟังก์ชันที่กำหนดเองได้
การวิเคราะห์งบการเงินด้วย Python

ฟังก์ชันที่กำหนดเองสำหรับคำนวณอัตราส่วน

def compute_ratio(df, numerator, denominator, ratio_name):
      df[ratio_name] = df[numerator]/df[denominator]
      return df

คำนวณ current ratio และ debt-to-equity ratio จาก DataFrame balance_sheet โดยใช้ compute_ratio:

balance_sheet = compute_ratio(balance_sheet, "Total Current Assets",
                        "Total Current Liabilities", "current_ratio")
balance_sheet = compute_ratio(balance_sheet, "Total Liab",
                        "Total Stockholder Equity", "debt_to_equity")
การวิเคราะห์งบการเงินด้วย Python

ฟังก์ชันที่กำหนดเองสำหรับคำนวณอัตราส่วน

  • กำหนดตัวเศษ ตัวส่วน และชื่ออัตราส่วนในลิสต์แยกกัน:
    list_of_numerators = ["Total Current Assets", "Total Liab"]            
    list_of_denominators = ["Total Current Liabilities", 
                          "Total Stockholder Equity"]
    list_of_ratio_names = ["current_ratio", "debt_to_equity"]
    
  • วนลูปผ่านลิสต์และเรียกใช้ฟังก์ชัน compute_ratio:

    for numerator, denominator, ratio_name in zip(list_of_numerators,
                                                  list_of_denominators,
                                                  list_of_ratio_names):
    
        balance_sheet = compute_ratio(balance_sheet, 
                numerator,
                denominator, 
                ratio_name)
    
การวิเคราะห์งบการเงินด้วย Python

มาฝึกกันเถอะ!

การวิเคราะห์งบการเงินด้วย Python

Preparing Video For Download...