Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -177,33 +177,34 @@ if st.session_state.df is not None:
|
|
| 177 |
fig = px.box(st.session_state.df, x="job_title", y="salary_in_usd",
|
| 178 |
title="Salary Distribution by Job Title")
|
| 179 |
|
| 180 |
-
# Insert visualization after "
|
| 181 |
-
insert_section = "
|
| 182 |
if insert_section in result:
|
| 183 |
-
# Split the report at the "Company Size" section
|
| 184 |
parts = result.split(insert_section)
|
| 185 |
-
st.markdown(parts[0]) #
|
| 186 |
-
st.markdown(f"## {insert_section}{parts[1].split('
|
| 187 |
-
|
| 188 |
# Insert the visualization here
|
| 189 |
st.plotly_chart(fig, use_container_width=True)
|
| 190 |
|
| 191 |
# Continue with the rest of the report
|
| 192 |
-
st.markdown("##
|
| 193 |
else:
|
| 194 |
-
#
|
| 195 |
st.markdown(result)
|
| 196 |
st.plotly_chart(fig, use_container_width=True)
|
| 197 |
else:
|
| 198 |
st.markdown(result)
|
| 199 |
|
| 200 |
-
# Tab 2: Full Data Visualization
|
| 201 |
with tab2:
|
| 202 |
st.subheader("π Comprehensive Data Visualizations")
|
| 203 |
|
|
|
|
| 204 |
fig1 = px.histogram(st.session_state.df, x="job_title", title="Job Title Frequency")
|
| 205 |
st.plotly_chart(fig1)
|
| 206 |
|
|
|
|
| 207 |
fig2 = px.bar(
|
| 208 |
st.session_state.df.groupby("experience_level")["salary_in_usd"].mean().reset_index(),
|
| 209 |
x="experience_level", y="salary_in_usd",
|
|
@@ -211,10 +212,22 @@ if st.session_state.df is not None:
|
|
| 211 |
)
|
| 212 |
st.plotly_chart(fig2)
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
temp_dir.cleanup()
|
| 215 |
else:
|
| 216 |
st.info("Please load a dataset to proceed.")
|
| 217 |
|
|
|
|
| 218 |
with st.sidebar:
|
| 219 |
st.header("π Reference:")
|
| 220 |
st.markdown("[SQL Agents w CrewAI & Llama 3 - Plaban Nayak](https://github.com/plaban1981/Agents/blob/main/SQL_Agents_with_CrewAI_and_Llama_3.ipynb)")
|
|
|
|
| 177 |
fig = px.box(st.session_state.df, x="job_title", y="salary_in_usd",
|
| 178 |
title="Salary Distribution by Job Title")
|
| 179 |
|
| 180 |
+
# Insert visualization after "4. Geographic Salary Variations" for better context
|
| 181 |
+
insert_section = "4. Geographic Salary Variations"
|
| 182 |
if insert_section in result:
|
|
|
|
| 183 |
parts = result.split(insert_section)
|
| 184 |
+
st.markdown(parts[0]) # Show content before section
|
| 185 |
+
st.markdown(f"## {insert_section}{parts[1].split('5.')[0]}") # Show the section content
|
| 186 |
+
|
| 187 |
# Insert the visualization here
|
| 188 |
st.plotly_chart(fig, use_container_width=True)
|
| 189 |
|
| 190 |
# Continue with the rest of the report
|
| 191 |
+
st.markdown("## 5." + parts[1].split("5.")[1])
|
| 192 |
else:
|
| 193 |
+
# Default behavior if the section isn't found
|
| 194 |
st.markdown(result)
|
| 195 |
st.plotly_chart(fig, use_container_width=True)
|
| 196 |
else:
|
| 197 |
st.markdown(result)
|
| 198 |
|
| 199 |
+
# Tab 2: Enhanced Full Data Visualization
|
| 200 |
with tab2:
|
| 201 |
st.subheader("π Comprehensive Data Visualizations")
|
| 202 |
|
| 203 |
+
# Histogram of job titles
|
| 204 |
fig1 = px.histogram(st.session_state.df, x="job_title", title="Job Title Frequency")
|
| 205 |
st.plotly_chart(fig1)
|
| 206 |
|
| 207 |
+
# Bar chart of average salary by experience level
|
| 208 |
fig2 = px.bar(
|
| 209 |
st.session_state.df.groupby("experience_level")["salary_in_usd"].mean().reset_index(),
|
| 210 |
x="experience_level", y="salary_in_usd",
|
|
|
|
| 212 |
)
|
| 213 |
st.plotly_chart(fig2)
|
| 214 |
|
| 215 |
+
# New Visualization: Salary by Employment Type
|
| 216 |
+
fig3 = px.box(st.session_state.df, x="employment_type", y="salary_in_usd",
|
| 217 |
+
title="Salary Distribution by Employment Type")
|
| 218 |
+
st.plotly_chart(fig3)
|
| 219 |
+
|
| 220 |
+
# New Visualization: Salary by Company Size (if available)
|
| 221 |
+
if "company_size" in st.session_state.df.columns:
|
| 222 |
+
fig4 = px.box(st.session_state.df, x="company_size", y="salary_in_usd",
|
| 223 |
+
title="Salary Distribution by Company Size")
|
| 224 |
+
st.plotly_chart(fig4)
|
| 225 |
+
|
| 226 |
temp_dir.cleanup()
|
| 227 |
else:
|
| 228 |
st.info("Please load a dataset to proceed.")
|
| 229 |
|
| 230 |
+
# Sidebar Reference
|
| 231 |
with st.sidebar:
|
| 232 |
st.header("π Reference:")
|
| 233 |
st.markdown("[SQL Agents w CrewAI & Llama 3 - Plaban Nayak](https://github.com/plaban1981/Agents/blob/main/SQL_Agents_with_CrewAI_and_Llama_3.ipynb)")
|