import streamlit as st import pandas as pd import matplotlib.pyplot as plt from streamlit.components.v1 import html import nbformat from nbconvert import HTMLExporter # Load the CSV data file_path = 'category upwork jobs.csv' jobs_df = pd.read_csv(file_path) # Adjust column names as per the CSV category_column = 'category' # Replace with the actual column name for category job_title_column = 'title' # Replace with the actual column name for job title description_column = 'Description' key_column = 'key' date_column = 'Date' # Sidebar menu st.sidebar.title("Navigation") option = st.sidebar.radio("Go to", ["Home", "Plots", "Notebook","Download Datasets"]) # Home Page: Display data with category filter if option == "Home": st.title("Jobs Dashboard") # Filter Jobs by Category st.sidebar.header("Filter Jobs by Category") categories = jobs_df[category_column].unique() # Extract unique categories selected_category = st.sidebar.selectbox("Choose a category:", categories) # Filter jobs based on the selected category filtered_jobs = jobs_df[jobs_df[category_column] == selected_category] # Display filtered jobs with additional columns st.write(f"Showing jobs in category: **{selected_category}**") st.dataframe(filtered_jobs[['title','key','description','date']]) # Optional: Show a count of jobs in the selected category st.write(f"Total jobs in this category: {len(filtered_jobs)}") # Plots Page: Display category distribution plot elif option == "Plots": st.title("Job Category Distribution") # Count occurrences of each category category_counts = jobs_df[category_column].value_counts() # Create a bar plot using matplotlib fig, ax = plt.subplots(figsize=(12, 6)) ax.bar(category_counts.index, category_counts.values) ax.set_xlabel("Job Category") ax.set_ylabel("Number of Jobs") ax.set_title("Distribution of Jobs Across Categories") plt.xticks(rotation=45, ha="right") plt.tight_layout() # Display the plot in Streamlit st.pyplot(fig) # Notebook Page: Render the Jupyter Notebook elif option == "Notebook": st.title("Jupyter Notebook") # Load and convert the notebook to HTML notebook_path = 'upwork_dashboard.ipynb' # Update with the actual path to your notebook with open(notebook_path) as f: notebook_content = nbformat.read(f, as_version=4) html_exporter = HTMLExporter() html_exporter.exclude_input = False # Include code cells in the notebook display notebook_html, _ = html_exporter.from_notebook_node(notebook_content) # Display the notebook HTML in Streamlit html(notebook_html, height=800, scrolling=True) elif option == "Download Datasets": st.title("Download Datasets") d=pd.read_csv("category upwork jobs.csv") d1=pd.read_csv("jobs.csv") # Download links for the datasets st.markdown("Click the links below to download the datasets:") # Link for category upwork jobs dataset with open("category upwork jobs.csv", 'rb') as f: st.download_button( label="Download Category Upwork Jobs Dataset", data=f, file_name='category_upwork_jobs.csv', mime='text/csv' ) st.dataframe(d) # Link for the original dataset with open("jobs.csv", 'rb') as f: st.download_button( label="Download Original Dataset", data=f, file_name='origina scraped data.csv', mime='text/csv' ) st.dataframe(d1)