---
# System prepended metadata

title: 4. 答案

---

# 4. 答案

```
## 允許python執行postgresql語法
with conn.cursor() as cur:

    sql = """
    SELECT * FROM sepsis.gcs_24
    """
    cur.execute(sql)
    name = [desc[0] for desc in cur.description]
    GCS = pd.DataFrame(cur.fetchall(),columns=name)
    
    print(cur.rowcount)
    
    sql = """
    SELECT * FROM sepsis.lab_24
    """
    cur.execute(sql)
    name = [desc[0] for desc in cur.description]
    LAB = pd.DataFrame(cur.fetchall(),columns=name)
    
    print(cur.rowcount)
    
    sql = """
    SELECT * FROM sepsis.sapsii
    """
    cur.execute(sql)
    name = [desc[0] for desc in cur.description]
    SAPSII = pd.DataFrame(cur.fetchall(),columns=name)
    
    print(cur.rowcount)
    
    sql = """
    SELECT * FROM sepsis.uo_24
    """
    cur.execute(sql)
    name = [desc[0] for desc in cur.description]
    UO = pd.DataFrame(cur.fetchall(),columns=name)
    
    print(cur.rowcount)
    
    sql = """
    SELECT * FROM sepsis.vital_24
    """
    cur.execute(sql)
    name = [desc[0] for desc in cur.description]
    Vital = pd.DataFrame(cur.fetchall(),columns=name)
    
    print(cur.rowcount)
```

```
fig = plt.figure(figsize=(30,24))
count = 0
for variable in All_num.columns[:6]:
    count += 1
    plt.subplot(2, 3, count)
    
    ax = sns.boxplot(x = All.gender, y=variable, data=All_num)
    ax = sns.stripplot(x = All.gender, y=variable, data=All_num, color="yellow", size=0.5)

plt.show()
```

```
size = [len(All_num[All_num.mortality_90d==0]) , len(All_num[All_num.mortality_90d==1])]
label = ['non-Mortality','Mortality']
plt.pie(size , labels = label, autopct='%1.0f%%')

```