Update app.py
Browse files
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"
|
| 143 |
-
|
| 144 |
|
| 145 |
def filter_csv(col, val):
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
return
|
| 149 |
-
return
|
| 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 |
-
#
|
| 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 |
-
#
|
| 175 |
-
|
| 176 |
-
summary_md
|
| 177 |
-
|
| 178 |
-
|
| 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():
|