All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
- 新增 utils/df_helpers.py 放共用 find_col(避免 routes/services 雙向依賴) - 新增 services/daily_sales_service.py 收: * get_taiwan_holiday(date) * prepare_calendar_data(df, selected_month) * prepare_marketing_summary(df, ...) - routes/daily_sales_routes.py 改為 import service,行數 949 → 713(-236) - 行為 100% 保留,僅檔案位置搬移
19 lines
501 B
Python
19 lines
501 B
Python
"""DataFrame 共用工具 — 跨 routes/services 共享。"""
|
|
|
|
|
|
def find_col(df_cols, keywords):
|
|
"""從欄位列表中,根據關鍵字列表找出最匹配的欄位名稱。
|
|
|
|
Args:
|
|
df_cols: DataFrame 的欄位名稱 iterable
|
|
keywords: 關鍵字列表,依優先序
|
|
|
|
Returns:
|
|
匹配的欄位名稱字串,找不到則回傳 None
|
|
"""
|
|
for k in keywords:
|
|
for col in df_cols:
|
|
if k in str(col):
|
|
return col
|
|
return None
|