Spaces:
Sleeping
Sleeping
Commit Β·
97f014a
1
Parent(s): b6e85e1
updated
Browse files
app.py
CHANGED
|
@@ -16,9 +16,11 @@ def load_csv(file):
|
|
| 16 |
return None, f"β CSV must contain {required_cols}"
|
| 17 |
|
| 18 |
# Add Age Group
|
| 19 |
-
df["Age Group"] = pd.cut(
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
return df, "β
File loaded successfully!"
|
| 23 |
except Exception as e:
|
| 24 |
return None, f"β Error: {e}"
|
|
@@ -48,10 +50,11 @@ def salary_chart():
|
|
| 48 |
plt.xticks(rotation=45)
|
| 49 |
plt.grid(axis="y", linestyle="--", alpha=0.7)
|
| 50 |
plt.tight_layout()
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
def performance_chart():
|
|
@@ -65,10 +68,11 @@ def performance_chart():
|
|
| 65 |
plt.xticks(rotation=45)
|
| 66 |
plt.grid(True, linestyle="--", alpha=0.6)
|
| 67 |
plt.tight_layout()
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
def search_employee(query):
|
|
@@ -98,8 +102,9 @@ with gr.Blocks() as demo:
|
|
| 98 |
salary_btn = gr.Button("π° Salary Chart")
|
| 99 |
performance_btn = gr.Button("π Performance Chart")
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
|
|
|
| 103 |
|
| 104 |
# Events
|
| 105 |
file_input.change(load_csv, inputs=file_input, outputs=[data_table, status])
|
|
|
|
| 16 |
return None, f"β CSV must contain {required_cols}"
|
| 17 |
|
| 18 |
# Add Age Group
|
| 19 |
+
df["Age Group"] = pd.cut(
|
| 20 |
+
df["Age"],
|
| 21 |
+
bins=[20, 25, 30, 35, 40],
|
| 22 |
+
labels=["21-25", "26-30", "31-35", "36-40"]
|
| 23 |
+
)
|
| 24 |
return df, "β
File loaded successfully!"
|
| 25 |
except Exception as e:
|
| 26 |
return None, f"β Error: {e}"
|
|
|
|
| 50 |
plt.xticks(rotation=45)
|
| 51 |
plt.grid(axis="y", linestyle="--", alpha=0.7)
|
| 52 |
plt.tight_layout()
|
| 53 |
+
|
| 54 |
+
filepath = "salary_chart.png"
|
| 55 |
+
plt.savefig(filepath)
|
| 56 |
+
plt.close()
|
| 57 |
+
return filepath
|
| 58 |
|
| 59 |
|
| 60 |
def performance_chart():
|
|
|
|
| 68 |
plt.xticks(rotation=45)
|
| 69 |
plt.grid(True, linestyle="--", alpha=0.6)
|
| 70 |
plt.tight_layout()
|
| 71 |
+
|
| 72 |
+
filepath = "performance_chart.png"
|
| 73 |
+
plt.savefig(filepath)
|
| 74 |
+
plt.close()
|
| 75 |
+
return filepath
|
| 76 |
|
| 77 |
|
| 78 |
def search_employee(query):
|
|
|
|
| 102 |
salary_btn = gr.Button("π° Salary Chart")
|
| 103 |
performance_btn = gr.Button("π Performance Chart")
|
| 104 |
|
| 105 |
+
# β
Fixed: use "filepath"
|
| 106 |
+
salary_plot = gr.Image(type="filepath", label="Salary Chart")
|
| 107 |
+
performance_plot = gr.Image(type="filepath", label="Performance Chart")
|
| 108 |
|
| 109 |
# Events
|
| 110 |
file_input.change(load_csv, inputs=file_input, outputs=[data_table, status])
|