fortuala commited on
Commit
361f65b
Β·
verified Β·
1 Parent(s): 112056c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -139,15 +139,14 @@ def make_images(scen):
139
 
140
 
141
  # ───────────────────── 4. CSV-table simple filter ──────────────────────
142
- CSV_FILE = "table_1_2.csv" # rename if needed
143
-
144
 
145
  def filter_csv(col, val):
146
- df = pd.read_csv(CSV_FILE)
147
- if col and val and col in df.columns:
148
- return df[df[col].astype(str).str.contains(val, case=False, na=False)]
149
- return df
150
-
151
 
152
  # ───────────────────── 5. Gradio interface ─────────────────────────────
153
  with gr.Blocks(title="Data Quality Scenario Explorer") as demo:
@@ -163,21 +162,19 @@ with gr.Blocks(title="Data Quality Scenario Explorer") as demo:
163
  value="0",
164
  )
165
 
166
- # three images side-by-side
167
  with gr.Row():
168
- im1 = gr.Image()
169
- im2 = gr.Image()
170
- im3 = gr.Image()
171
  scen.change(make_images, scen, [im1, im2, im3])
172
  demo.load(lambda: make_images("0"), outputs=[im1, im2, im3])
173
 
174
- # button -> full markdown
175
- show_btn = gr.Button("Data Validation Summary")
176
- summary_md = gr.Markdown(visible=False)
177
- show_btn.click(lambda: gr.update(value=QUALITY_TEXT, visible=True),
178
- inputs=None, outputs=summary_md)
179
 
180
- # table viewer
181
  gr.Markdown("### Table 1-2 Viewer")
182
 
183
  with gr.Row():
 
139
 
140
 
141
  # ───────────────────── 4. CSV-table simple filter ──────────────────────
142
+ CSV_FILE = "table_1_2.csv" # rename here if needed
143
+ df_full = pd.read_csv(CSV_FILE) # load once
144
 
145
  def filter_csv(col, val):
146
+ if col and val:
147
+ mask = df_full[col].astype(str).str.contains(val, case=False, na=False)
148
+ return df_full[mask]
149
+ return df_full
 
150
 
151
  # ───────────────────── 5. Gradio interface ─────────────────────────────
152
  with gr.Blocks(title="Data Quality Scenario Explorer") as demo:
 
162
  value="0",
163
  )
164
 
165
+ # plots side-by-side
166
  with gr.Row():
167
+ im1, im2, im3 = gr.Image(), gr.Image(), gr.Image()
 
 
168
  scen.change(make_images, scen, [im1, im2, im3])
169
  demo.load(lambda: make_images("0"), outputs=[im1, im2, im3])
170
 
171
+ # summary text button
172
+ summary_btn = gr.Button("Data Validation Summary")
173
+ summary_md = gr.Markdown(visible=False)
174
+ summary_btn.click(lambda: gr.update(value=QUALITY_TEXT, visible=True),
175
+ inputs=None, outputs=summary_md)
176
 
177
+ # ──────── table viewer with universal filter ─────────
178
  gr.Markdown("### Table 1-2 Viewer")
179
 
180
  with gr.Row():