Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -66,14 +66,23 @@ def generate_visuals(filtered_data):
|
|
66 |
plt.ylabel("Count")
|
67 |
plt.tight_layout()
|
68 |
country_chart = gr.Plot(plt.gcf())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
return gender_chart, country_chart
|
71 |
|
72 |
# Gradio Interface
|
73 |
def app(fiscal_year, employer, job_title, country_of_birth, country_of_nationality, min_salary, max_salary, worksite_city, worksite_state):
|
74 |
filtered = filter_data(fiscal_year, employer, job_title, country_of_birth, country_of_nationality, min_salary, max_salary, worksite_city, worksite_state)
|
75 |
-
gender_chart, country_chart = generate_visuals(filtered)
|
76 |
-
return filtered, gender_chart, country_chart
|
77 |
|
78 |
# Dropdown options
|
79 |
fiscal_years = ["All"] + sorted(data['fiscal_year'].dropna().unique().astype(str).tolist())
|
@@ -109,15 +118,16 @@ with gr.Blocks() as demo:
|
|
109 |
with gr.Row():
|
110 |
apply_filters = gr.Button("Apply Filters")
|
111 |
|
112 |
-
|
113 |
output_table = gr.Dataframe(label="Filtered Data")
|
114 |
gender_chart = gr.Plot()
|
115 |
country_chart = gr.Plot()
|
|
|
116 |
|
117 |
apply_filters.click(
|
118 |
app,
|
119 |
inputs=[fiscal_year, employer, job_title, country_of_birth, country_of_nationality, min_salary, max_salary, worksite_city, worksite_state],
|
120 |
-
outputs=[output_table, gender_chart, country_chart]
|
121 |
)
|
122 |
|
123 |
demo.launch()
|
|
|
66 |
plt.ylabel("Count")
|
67 |
plt.tight_layout()
|
68 |
country_chart = gr.Plot(plt.gcf())
|
69 |
+
|
70 |
+
# Salary by Gender Histogram
|
71 |
+
plt.figure(figsize=(12, 8))
|
72 |
+
sns.histplot(data=filtered_data, x='wage_amt', hue='gender', multiple="stack", kde=True)
|
73 |
+
plt.title("Salary Distribution by Gender")
|
74 |
+
plt.xlabel("Salary (USD)")
|
75 |
+
plt.ylabel("Frequency")
|
76 |
+
plt.tight_layout()
|
77 |
+
salary_gender_hist = gr.Plot(plt.gcf())
|
78 |
|
79 |
+
return gender_chart, country_chart, salary_gender_hist
|
80 |
|
81 |
# Gradio Interface
|
82 |
def app(fiscal_year, employer, job_title, country_of_birth, country_of_nationality, min_salary, max_salary, worksite_city, worksite_state):
|
83 |
filtered = filter_data(fiscal_year, employer, job_title, country_of_birth, country_of_nationality, min_salary, max_salary, worksite_city, worksite_state)
|
84 |
+
gender_chart, country_chart, salary_gender_hist = generate_visuals(filtered)
|
85 |
+
return filtered, gender_chart, country_chart, salary_gender_hist
|
86 |
|
87 |
# Dropdown options
|
88 |
fiscal_years = ["All"] + sorted(data['fiscal_year'].dropna().unique().astype(str).tolist())
|
|
|
118 |
with gr.Row():
|
119 |
apply_filters = gr.Button("Apply Filters")
|
120 |
|
121 |
+
# Output components
|
122 |
output_table = gr.Dataframe(label="Filtered Data")
|
123 |
gender_chart = gr.Plot()
|
124 |
country_chart = gr.Plot()
|
125 |
+
salary_gender_hist = gr.Plot()
|
126 |
|
127 |
apply_filters.click(
|
128 |
app,
|
129 |
inputs=[fiscal_year, employer, job_title, country_of_birth, country_of_nationality, min_salary, max_salary, worksite_city, worksite_state],
|
130 |
+
outputs=[output_table, gender_chart, country_chart, salary_gender_hist]
|
131 |
)
|
132 |
|
133 |
demo.launch()
|