cyc00518 commited on
Commit
11240ae
·
1 Parent(s): b4ad566

fix: handle empty categories when threshold filter is off

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -165,7 +165,12 @@ cat_order = order_df["category"].tolist()
165
 
166
  # 如果篩選後沒有類別,顯示提示
167
  if not cat_order:
168
- st.warning(f"⚠️ 沒有類別符合篩選條件({threshold_mode}: {threshold_value}),請調整閾值或關閉篩選。")
 
 
 
 
 
169
  st.stop()
170
 
171
  work["category"] = pd.Categorical(work["category"], categories=cat_order, ordered=True)
 
165
 
166
  # 如果篩選後沒有類別,顯示提示
167
  if not cat_order:
168
+ if enable_threshold and threshold_mode is not None and threshold_value is not None:
169
+ st.warning(
170
+ f"⚠️ 沒有類別符合篩選條件({threshold_mode}: {threshold_value}),請調整閾值或關閉篩選。"
171
+ )
172
+ else:
173
+ st.warning("⚠️ 沒有可顯示的類別,請檢查資料集內容或調整篩選條件。")
174
  st.stop()
175
 
176
  work["category"] = pd.Categorical(work["category"], categories=cat_order, ordered=True)