Update app.py
Browse files
app.py
CHANGED
|
@@ -44,12 +44,14 @@ def clean_data(df):
|
|
| 44 |
def upload_file(file):
|
| 45 |
global df_global
|
| 46 |
if file is None:
|
| 47 |
-
return pd.DataFrame({"Error": ["No file uploaded."]})
|
| 48 |
ext = os.path.splitext(file.name)[-1]
|
| 49 |
df = pd.read_csv(file.name) if ext == ".csv" else pd.read_excel(file.name)
|
| 50 |
df = clean_data(df)
|
| 51 |
df_global = df
|
| 52 |
-
return df.head()
|
|
|
|
|
|
|
| 53 |
|
| 54 |
def set_target_column(col_name):
|
| 55 |
global target_column_global
|
|
@@ -387,7 +389,7 @@ with gr.Blocks() as demo:
|
|
| 387 |
target_dropdown = gr.Dropdown(label="Select Target Column", choices=[], interactive=True)
|
| 388 |
target_status = gr.Textbox(label="Target Column Status", interactive=False)
|
| 389 |
|
| 390 |
-
file_input.change(fn=upload_file, inputs=file_input, outputs=df_output)
|
| 391 |
file_input.change(fn=update_target_choices, inputs=[], outputs=target_dropdown)
|
| 392 |
target_dropdown.change(fn=set_target_column, inputs=target_dropdown, outputs=target_status)
|
| 393 |
|
|
|
|
| 44 |
def upload_file(file):
|
| 45 |
global df_global
|
| 46 |
if file is None:
|
| 47 |
+
return pd.DataFrame({"Error": ["No file uploaded."]}), gr.update(choices=[])
|
| 48 |
ext = os.path.splitext(file.name)[-1]
|
| 49 |
df = pd.read_csv(file.name) if ext == ".csv" else pd.read_excel(file.name)
|
| 50 |
df = clean_data(df)
|
| 51 |
df_global = df
|
| 52 |
+
return df.head(), gr.update(choices=df.columns.tolist())
|
| 53 |
+
|
| 54 |
+
|
| 55 |
|
| 56 |
def set_target_column(col_name):
|
| 57 |
global target_column_global
|
|
|
|
| 389 |
target_dropdown = gr.Dropdown(label="Select Target Column", choices=[], interactive=True)
|
| 390 |
target_status = gr.Textbox(label="Target Column Status", interactive=False)
|
| 391 |
|
| 392 |
+
file_input.change(fn=upload_file, inputs=file_input, outputs=[df_output, target_dropdown])
|
| 393 |
file_input.change(fn=update_target_choices, inputs=[], outputs=target_dropdown)
|
| 394 |
target_dropdown.change(fn=set_target_column, inputs=target_dropdown, outputs=target_status)
|
| 395 |
|