Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,100 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Load the CSV data
|
5 |
file_path = 'category upwork jobs.csv'
|
6 |
jobs_df = pd.read_csv(file_path)
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
#
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
# Optional: Show a count of jobs in the selected category
|
23 |
-
st.write(f"Total jobs in this category: {len(filtered_jobs)}")
|
|
|
1 |
+
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
from streamlit.components.v1 import html
|
6 |
+
import nbformat
|
7 |
+
from nbconvert import HTMLExporter
|
8 |
|
9 |
# Load the CSV data
|
10 |
file_path = 'category upwork jobs.csv'
|
11 |
jobs_df = pd.read_csv(file_path)
|
12 |
|
13 |
+
# Adjust column names as per the CSV
|
14 |
+
category_column = 'category' # Replace with the actual column name for category
|
15 |
+
job_title_column = 'title' # Replace with the actual column name for job title
|
16 |
+
description_column = 'Description'
|
17 |
+
key_column = 'key'
|
18 |
+
date_column = 'Date'
|
19 |
+
|
20 |
+
# Sidebar menu
|
21 |
+
st.sidebar.title("Navigation")
|
22 |
+
option = st.sidebar.radio("Go to", ["Home", "Plots", "Notebook","Download Datasets"])
|
23 |
+
# Home Page: Display data with category filter
|
24 |
+
if option == "Home":
|
25 |
+
st.title("Jobs Dashboard")
|
26 |
+
|
27 |
+
# Filter Jobs by Category
|
28 |
+
st.sidebar.header("Filter Jobs by Category")
|
29 |
+
categories = jobs_df[category_column].unique() # Extract unique categories
|
30 |
+
selected_category = st.sidebar.selectbox("Choose a category:", categories)
|
31 |
+
|
32 |
+
# Filter jobs based on the selected category
|
33 |
+
filtered_jobs = jobs_df[jobs_df[category_column] == selected_category]
|
34 |
+
|
35 |
+
# Display filtered jobs with additional columns
|
36 |
+
st.write(f"Showing jobs in category: **{selected_category}**")
|
37 |
+
st.dataframe(filtered_jobs[['title','key','description','date']])
|
38 |
+
|
39 |
+
# Optional: Show a count of jobs in the selected category
|
40 |
+
st.write(f"Total jobs in this category: {len(filtered_jobs)}")
|
41 |
+
|
42 |
+
# Plots Page: Display category distribution plot
|
43 |
+
elif option == "Plots":
|
44 |
+
st.title("Job Category Distribution")
|
45 |
+
|
46 |
+
# Count occurrences of each category
|
47 |
+
category_counts = jobs_df[category_column].value_counts()
|
48 |
+
|
49 |
+
# Create a bar plot using matplotlib
|
50 |
+
fig, ax = plt.subplots(figsize=(12, 6))
|
51 |
+
ax.bar(category_counts.index, category_counts.values)
|
52 |
+
ax.set_xlabel("Job Category")
|
53 |
+
ax.set_ylabel("Number of Jobs")
|
54 |
+
ax.set_title("Distribution of Jobs Across Categories")
|
55 |
+
plt.xticks(rotation=45, ha="right")
|
56 |
+
plt.tight_layout()
|
57 |
+
|
58 |
+
# Display the plot in Streamlit
|
59 |
+
st.pyplot(fig)
|
60 |
+
# Notebook Page: Render the Jupyter Notebook
|
61 |
+
elif option == "Notebook":
|
62 |
+
st.title("Jupyter Notebook")
|
63 |
|
64 |
+
# Load and convert the notebook to HTML
|
65 |
+
notebook_path = 'upwork_dashboard.ipynb' # Update with the actual path to your notebook
|
66 |
+
with open(notebook_path) as f:
|
67 |
+
notebook_content = nbformat.read(f, as_version=4)
|
68 |
+
|
69 |
+
html_exporter = HTMLExporter()
|
70 |
+
html_exporter.exclude_input = False # Include code cells in the notebook display
|
71 |
+
notebook_html, _ = html_exporter.from_notebook_node(notebook_content)
|
72 |
|
73 |
+
# Display the notebook HTML in Streamlit
|
74 |
+
html(notebook_html, height=800, scrolling=True)
|
75 |
+
elif option == "Download Datasets":
|
76 |
+
st.title("Download Datasets")
|
77 |
+
d=pd.read_csv("category upwork jobs.csv")
|
78 |
+
d1=pd.read_csv("jobs.csv")
|
79 |
+
# Download links for the datasets
|
80 |
+
st.markdown("Click the links below to download the datasets:")
|
81 |
+
|
82 |
+
# Link for category upwork jobs dataset
|
83 |
+
with open("category upwork jobs.csv", 'rb') as f:
|
84 |
+
st.download_button(
|
85 |
+
label="Download Category Upwork Jobs Dataset",
|
86 |
+
data=f,
|
87 |
+
file_name='category_upwork_jobs.csv',
|
88 |
+
mime='text/csv'
|
89 |
+
)
|
90 |
+
st.dataframe(d)
|
91 |
+
# Link for the original dataset
|
92 |
+
with open("jobs.csv", 'rb') as f:
|
93 |
+
st.download_button(
|
94 |
+
label="Download Original Dataset",
|
95 |
+
data=f,
|
96 |
+
file_name='origina scraped data.csv',
|
97 |
+
mime='text/csv'
|
98 |
+
)
|
99 |
+
st.dataframe(d1)
|
100 |
|
|
|
|