Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1720,18 +1720,30 @@ with gr.Blocks(css=css, title="DataSynth — Analytics Hub") as demo:
|
|
| 1720 |
outputs=[prep_output, clean_state]
|
| 1721 |
)
|
| 1722 |
|
| 1723 |
-
#
|
| 1724 |
-
def
|
| 1725 |
-
|
| 1726 |
-
|
| 1727 |
-
|
| 1728 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1729 |
|
| 1730 |
-
|
| 1731 |
-
|
|
|
|
|
|
|
|
|
|
| 1732 |
|
| 1733 |
-
select_all_cols.click(fn=
|
| 1734 |
-
deselect_all_cols.click(fn=
|
| 1735 |
|
| 1736 |
# Show/hide custom value inputs based on method selection
|
| 1737 |
def _toggle_custom_inputs(num_method, cat_method):
|
|
|
|
| 1720 |
outputs=[prep_output, clean_state]
|
| 1721 |
)
|
| 1722 |
|
| 1723 |
+
# safe helper: read columns from persisted df path
|
| 1724 |
+
def _cols_from_df_path(df_path):
|
| 1725 |
+
try:
|
| 1726 |
+
if not df_path:
|
| 1727 |
+
return []
|
| 1728 |
+
df = pd.read_csv(df_path)
|
| 1729 |
+
return [str(c) for c in df.columns]
|
| 1730 |
+
except Exception:
|
| 1731 |
+
return []
|
| 1732 |
+
|
| 1733 |
+
# callback for Select All button
|
| 1734 |
+
def select_all_cols(df_path):
|
| 1735 |
+
cols = _cols_from_df_path(df_path)
|
| 1736 |
+
# return gr.update(...) (NOT component.update). Set both choices and value.
|
| 1737 |
+
return gr.update(choices=cols, value=cols)
|
| 1738 |
|
| 1739 |
+
# callback for Deselect All button
|
| 1740 |
+
def deselect_all_cols(df_path):
|
| 1741 |
+
cols = _cols_from_df_path(df_path)
|
| 1742 |
+
# keep choices, but clear value to deselect all
|
| 1743 |
+
return gr.update(choices=cols, value=[])
|
| 1744 |
|
| 1745 |
+
select_all_cols.click(fn=select_all_cols, inputs=[df_state], outputs=[available_cols])
|
| 1746 |
+
deselect_all_cols.click(fn=deselect_all_cols, inputs=[df_state], outputs=[available_cols])
|
| 1747 |
|
| 1748 |
# Show/hide custom value inputs based on method selection
|
| 1749 |
def _toggle_custom_inputs(num_method, cat_method):
|