一、案例定位

原書用 Sally Suite 的 Data Analysis 功能計算各 Department 病患數;除了把 static table 寫入 Excel,Sally Suite 還提供對應 Python code,展示結果如何脫離 add-in 重新執行。

二、學習目標

三、案例情境

Prompt:Consider Table1. Calculate the number of patients for each department. 使用者確認後,結果可用 New Sheet 放入新工作表。

四、開始資料

環節 原書行為
Input Table1 / Department
Output Department + Number of Patients table
Result type Static values,而非 dynamic formulas
Python df['Department'].value_counts().reset_index()

五、Excel/R/AI 分析方法

Sally Suite 讀取 /input/data.xlsx 的 patients sheet,先檢查 Department 欄是否存在,再用 pandas value_counts() 建立 Department/Number of Patients,最後輸出 Markdown table 到 /output/patient_department_counts.md。

六、計算結果

Figure 11-11 顯示結果表,但 A 檔正文沒有列出每個 Department 的 count。可確認 Python 邏輯是依 Department 做頻數統計。

七、結果分析與管理解讀

Static output 不會隨來源表自動更新,因此若 patient data 改變,必須重新執行分析。能取得 Python code 的好處是 workflow 變得更透明、可移植,也更容易 audit。

八、AI 提問詞

請計算每個 Department 的 patient count,並同時提供可重跑的 Python code。輸出前先檢查 Department 欄存在;結果表請清楚標示為 static snapshot,除非建立了動態更新機制。

九、思考/情境變動

**問題:**來源表新增 20 筆病患後,原本 Sally Suite 產生的 static table 會自動更新嗎?