Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -87,34 +87,9 @@ def create_chart(data, _x, y, title, color_sequence):
|
|
87 |
fig.update_layout(plot_bgcolor='rgba(0,0,0,0)', paper_bgcolor='rgba(0,0,0,0)', font_color='#FFFFFF')
|
88 |
return fig
|
89 |
|
90 |
-
def
|
91 |
-
|
92 |
-
|
93 |
-
expanded_df = df.reindex(full_range).reset_index()
|
94 |
-
expanded_df.columns = ['Week', 'Job Postings']
|
95 |
-
expanded_df['Job Postings'] = expanded_df['Job Postings'].fillna(0)
|
96 |
-
return expanded_df
|
97 |
-
|
98 |
-
def create_weekly_dashboard(df):
|
99 |
-
df['Week'] = df['date_posted'].dt.to_period('W').apply(lambda r: r.start_time)
|
100 |
-
weekly_data = df.groupby('Week').size().reset_index(name='Job Postings')
|
101 |
-
|
102 |
-
start_date = weekly_data['Week'].min()
|
103 |
-
end_date = weekly_data['Week'].max()
|
104 |
-
|
105 |
-
expanded_weekly_data = expand_time_series(weekly_data, 'Week', start_date, end_date)
|
106 |
-
return expanded_weekly_data
|
107 |
-
|
108 |
-
@st.cache_data
|
109 |
-
def get_location_data(df):
|
110 |
-
location_counts = df['location'].value_counts().reset_index()
|
111 |
-
location_counts.columns = ['location', 'count']
|
112 |
-
return location_counts
|
113 |
-
|
114 |
-
def create_heatmap(location_data):
|
115 |
-
fig = px.density_mapbox(location_data, lat='latitude', lon='longitude', z='count', radius=10,
|
116 |
-
center=dict(lat=37.0902, lon=-95.7129), zoom=3,
|
117 |
-
mapbox_style="carto-darkmatter", title="Job Postings Heatmap")
|
118 |
fig.update_layout(plot_bgcolor='rgba(0,0,0,0)', paper_bgcolor='rgba(0,0,0,0)', font_color='#FFFFFF')
|
119 |
return fig
|
120 |
|
@@ -136,11 +111,9 @@ def display_dashboard(df):
|
|
136 |
fig = create_chart(top_companies, top_companies.index, top_companies.values, "Top 10 Companies", ['#4e79a7'])
|
137 |
st.plotly_chart(fig, use_container_width=True)
|
138 |
|
139 |
-
#
|
140 |
-
|
141 |
-
|
142 |
-
fig_weekly.update_layout(plot_bgcolor='rgba(0,0,0,0)', paper_bgcolor='rgba(0,0,0,0)', font_color='#FFFFFF')
|
143 |
-
st.plotly_chart(fig_weekly, use_container_width=True)
|
144 |
|
145 |
col3, col4 = st.columns(2)
|
146 |
|
@@ -155,12 +128,6 @@ def display_dashboard(df):
|
|
155 |
fig.update_layout(plot_bgcolor='rgba(0,0,0,0)', paper_bgcolor='rgba(0,0,0,0)', font_color='#FFFFFF')
|
156 |
st.plotly_chart(fig, use_container_width=True)
|
157 |
|
158 |
-
# Job Postings Heatmap
|
159 |
-
st.subheader("Job Postings Heatmap")
|
160 |
-
location_data = get_location_data(df)
|
161 |
-
fig_heatmap = create_heatmap(location_data)
|
162 |
-
st.plotly_chart(fig_heatmap, use_container_width=True)
|
163 |
-
|
164 |
@st.cache_data
|
165 |
def filter_dataframe(df, companies, locations, job_types):
|
166 |
filtered_df = df
|
@@ -216,7 +183,7 @@ def main():
|
|
216 |
|
217 |
if page == "Dashboard":
|
218 |
display_dashboard(df)
|
219 |
-
elif page
|
220 |
display_data_explorer(df)
|
221 |
|
222 |
if __name__ == "__main__":
|
|
|
87 |
fig.update_layout(plot_bgcolor='rgba(0,0,0,0)', paper_bgcolor='rgba(0,0,0,0)', font_color='#FFFFFF')
|
88 |
return fig
|
89 |
|
90 |
+
def create_time_series(df):
|
91 |
+
df_by_date = df.groupby('date_posted').size().reset_index(name='count')
|
92 |
+
fig = px.line(df_by_date, x='date_posted', y='count', title="Job Postings Over Time", color_discrete_sequence=['#4e79a7'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
fig.update_layout(plot_bgcolor='rgba(0,0,0,0)', paper_bgcolor='rgba(0,0,0,0)', font_color='#FFFFFF')
|
94 |
return fig
|
95 |
|
|
|
111 |
fig = create_chart(top_companies, top_companies.index, top_companies.values, "Top 10 Companies", ['#4e79a7'])
|
112 |
st.plotly_chart(fig, use_container_width=True)
|
113 |
|
114 |
+
# Job Postings Over Time Chart
|
115 |
+
fig_time_series = create_time_series(df)
|
116 |
+
st.plotly_chart(fig_time_series, use_container_width=True)
|
|
|
|
|
117 |
|
118 |
col3, col4 = st.columns(2)
|
119 |
|
|
|
128 |
fig.update_layout(plot_bgcolor='rgba(0,0,0,0)', paper_bgcolor='rgba(0,0,0,0)', font_color='#FFFFFF')
|
129 |
st.plotly_chart(fig, use_container_width=True)
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
@st.cache_data
|
132 |
def filter_dataframe(df, companies, locations, job_types):
|
133 |
filtered_df = df
|
|
|
183 |
|
184 |
if page == "Dashboard":
|
185 |
display_dashboard(df)
|
186 |
+
elif page "Data Explorer":
|
187 |
display_data_explorer(df)
|
188 |
|
189 |
if __name__ == "__main__":
|