Update app.py
Browse files
app.py
CHANGED
|
@@ -207,61 +207,53 @@ if st.session_state.df is not None:
|
|
| 207 |
report_result = crew_report.kickoff(inputs={"query": query + " Provide detailed analysis but DO NOT include Conclusion."})
|
| 208 |
conclusion_result = crew_conclusion.kickoff(inputs={"query": query + " Provide ONLY the most important insights in 3-5 concise lines."})
|
| 209 |
|
| 210 |
-
|
| 211 |
-
report_text = str(report_result)
|
| 212 |
-
conclusion_text = str(conclusion_result)
|
| 213 |
|
| 214 |
-
st.markdown(report_text if report_text else "β οΈ No Report Generated.")
|
| 215 |
-
|
| 216 |
-
# Download Buttons for Tab 1
|
| 217 |
-
tab1_txt = save_as_txt(report_text, "Tab1_Report.txt")
|
| 218 |
-
tab1_pdf = save_as_pdf(report_text, "Tab1_Report.pdf")
|
| 219 |
-
st.download_button("Download Tab 1 Report as TXT", open(tab1_txt, "rb"), file_name="Tab1_Report.txt")
|
| 220 |
-
st.download_button("Download Tab 1 Report as PDF", open(tab1_pdf, "rb"), file_name="Tab1_Report.pdf")
|
| 221 |
-
|
| 222 |
-
# Visualizations with captions
|
| 223 |
fig_salary = px.box(st.session_state.df, x="job_title", y="salary_in_usd", title="Salary Distribution by Job Title")
|
| 224 |
-
st.plotly_chart(fig_salary)
|
| 225 |
st.caption("π Salary distribution across different job titles.")
|
| 226 |
|
| 227 |
-
fig_experience = px.bar(st.session_state.df.groupby("experience_level")["salary_in_usd"].mean().reset_index(),
|
| 228 |
-
|
| 229 |
-
st.
|
|
|
|
| 230 |
|
| 231 |
fig_employment = px.box(st.session_state.df, x="employment_type", y="salary_in_usd", title="Salary Distribution by Employment Type")
|
| 232 |
-
st.plotly_chart(fig_employment)
|
| 233 |
st.caption("π Salary distribution across employment types.")
|
| 234 |
|
| 235 |
-
st.markdown(conclusion_text if conclusion_text else "β οΈ No Conclusion Generated.")
|
| 236 |
-
|
| 237 |
# Full Data Visualization Tab
|
| 238 |
with tab2:
|
| 239 |
st.subheader("π Comprehensive Data Visualizations")
|
| 240 |
|
| 241 |
fig1 = px.histogram(st.session_state.df, x="job_title", title="Job Title Frequency")
|
| 242 |
-
st.plotly_chart(fig1)
|
| 243 |
st.caption("π Frequency of each job title in the dataset.")
|
| 244 |
|
| 245 |
fig2 = px.bar(st.session_state.df.groupby("experience_level")["salary_in_usd"].mean().reset_index(),
|
| 246 |
x="experience_level", y="salary_in_usd", title="Average Salary by Experience Level")
|
| 247 |
-
st.plotly_chart(fig2)
|
| 248 |
st.caption("π Average salary for each experience level.")
|
| 249 |
|
| 250 |
fig3 = px.box(st.session_state.df, x="employment_type", y="salary_in_usd", title="Salary Distribution by Employment Type")
|
| 251 |
-
st.plotly_chart(fig3)
|
| 252 |
st.caption("π Salary distribution across employment types.")
|
| 253 |
|
| 254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
tab2_txt = save_as_txt(tab2_content, "Tab2_Visualizations.txt")
|
| 256 |
tab2_pdf = save_as_pdf(tab2_content, "Tab2_Visualizations.pdf")
|
| 257 |
-
|
| 258 |
-
st.download_button("Download Tab 2 Summary as
|
| 259 |
-
st.download_button("Download Tab 2 Summary as PDF", open(tab2_pdf, "rb"), file_name="Tab2_Visualizations.pdf")
|
| 260 |
|
| 261 |
temp_dir.cleanup()
|
| 262 |
else:
|
| 263 |
st.info("Please load a dataset to proceed.")
|
| 264 |
-
|
| 265 |
# Sidebar Reference
|
| 266 |
with st.sidebar:
|
| 267 |
st.header("π Reference:")
|
|
|
|
| 207 |
report_result = crew_report.kickoff(inputs={"query": query + " Provide detailed analysis but DO NOT include Conclusion."})
|
| 208 |
conclusion_result = crew_conclusion.kickoff(inputs={"query": query + " Provide ONLY the most important insights in 3-5 concise lines."})
|
| 209 |
|
| 210 |
+
st.markdown(str(report_result) if report_result else "β οΈ No Report Generated.")
|
|
|
|
|
|
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
fig_salary = px.box(st.session_state.df, x="job_title", y="salary_in_usd", title="Salary Distribution by Job Title")
|
| 213 |
+
st.plotly_chart(fig_salary, use_container_width=True, key="fig_salary")
|
| 214 |
st.caption("π Salary distribution across different job titles.")
|
| 215 |
|
| 216 |
+
fig_experience = px.bar(st.session_state.df.groupby("experience_level")["salary_in_usd"].mean().reset_index(),
|
| 217 |
+
x="experience_level", y="salary_in_usd", title="Average Salary by Experience Level")
|
| 218 |
+
st.plotly_chart(fig_experience, use_container_width=True, key="fig_experience")
|
| 219 |
+
st.caption("π Average salary by experience level.")
|
| 220 |
|
| 221 |
fig_employment = px.box(st.session_state.df, x="employment_type", y="salary_in_usd", title="Salary Distribution by Employment Type")
|
| 222 |
+
st.plotly_chart(fig_employment, use_container_width=True, key="fig_employment")
|
| 223 |
st.caption("π Salary distribution across employment types.")
|
| 224 |
|
|
|
|
|
|
|
| 225 |
# Full Data Visualization Tab
|
| 226 |
with tab2:
|
| 227 |
st.subheader("π Comprehensive Data Visualizations")
|
| 228 |
|
| 229 |
fig1 = px.histogram(st.session_state.df, x="job_title", title="Job Title Frequency")
|
| 230 |
+
st.plotly_chart(fig1, key="fig1")
|
| 231 |
st.caption("π Frequency of each job title in the dataset.")
|
| 232 |
|
| 233 |
fig2 = px.bar(st.session_state.df.groupby("experience_level")["salary_in_usd"].mean().reset_index(),
|
| 234 |
x="experience_level", y="salary_in_usd", title="Average Salary by Experience Level")
|
| 235 |
+
st.plotly_chart(fig2, key="fig2")
|
| 236 |
st.caption("π Average salary for each experience level.")
|
| 237 |
|
| 238 |
fig3 = px.box(st.session_state.df, x="employment_type", y="salary_in_usd", title="Salary Distribution by Employment Type")
|
| 239 |
+
st.plotly_chart(fig3, key="fig3")
|
| 240 |
st.caption("π Salary distribution across employment types.")
|
| 241 |
|
| 242 |
+
# Restored Summary for Tab 2
|
| 243 |
+
tab2_content = "Comprehensive Data Visualizations:\n"
|
| 244 |
+
tab2_content += "- Job Title Frequency\n"
|
| 245 |
+
tab2_content += "- Average Salary by Experience Level\n"
|
| 246 |
+
tab2_content += "- Salary Distribution by Employment Type\n"
|
| 247 |
+
|
| 248 |
tab2_txt = save_as_txt(tab2_content, "Tab2_Visualizations.txt")
|
| 249 |
tab2_pdf = save_as_pdf(tab2_content, "Tab2_Visualizations.pdf")
|
| 250 |
+
st.download_button("π₯ Download Tab 2 Summary as TXT", open(tab2_txt, "rb"), file_name="Tab2_Visualizations.txt")
|
| 251 |
+
st.download_button("π₯ Download Tab 2 Summary as PDF", open(tab2_pdf, "rb"), file_name="Tab2_Visualizations.pdf")
|
|
|
|
| 252 |
|
| 253 |
temp_dir.cleanup()
|
| 254 |
else:
|
| 255 |
st.info("Please load a dataset to proceed.")
|
| 256 |
+
|
| 257 |
# Sidebar Reference
|
| 258 |
with st.sidebar:
|
| 259 |
st.header("π Reference:")
|