Niharmahesh commited on
Commit
4673149
·
verified ·
1 Parent(s): e615930

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -82,7 +82,8 @@ def load_and_concat_data():
82
 
83
  # Drop duplicates and rows with NaT in date_posted
84
  filtered_df = filtered_df.drop_duplicates().dropna(subset=['date_posted'])
85
-
 
86
  # Convert titles to lowercase
87
  filtered_df['title'] = filtered_df['title'].str.lower()
88
 
@@ -117,8 +118,15 @@ def create_chart(data, _x, y, title, color_sequence):
117
  fig.update_layout(plot_bgcolor='rgba(0,0,0,0)', paper_bgcolor='rgba(0,0,0,0)', font_color='#FFFFFF')
118
  return fig
119
 
120
- def create_time_series(df):
121
- df_by_date = df.groupby('date_posted').size().reset_index(name='count')
 
 
 
 
 
 
 
122
  fig = px.line(df_by_date, x='date_posted', y='count', title="Job Postings Over Time", color_discrete_sequence=['#4e79a7'])
123
  fig.update_layout(
124
  plot_bgcolor='rgba(0,0,0,0)',
@@ -127,6 +135,14 @@ def create_time_series(df):
127
  xaxis_title="Date",
128
  yaxis_title="Number of Job Postings"
129
  )
 
 
 
 
 
 
 
 
130
  return fig
131
 
132
  @st.cache_data
@@ -160,7 +176,7 @@ def display_dashboard(df):
160
  st.plotly_chart(fig, use_container_width=True)
161
 
162
  # Job Postings Over Time Chart
163
- fig_time_series = create_time_series(df)
164
  st.plotly_chart(fig_time_series, use_container_width=True)
165
 
166
  col3, col4 = st.columns(2)
@@ -239,16 +255,12 @@ def display_data_explorer(df):
239
  def display_about_page():
240
  st.markdown("""
241
  ## What is this application?
242
-
243
  The Job Listings Dashboard is a powerful tool designed to provide insights into the job market. It offers a comprehensive view of job postings, allowing users to explore trends, top companies, locations, and job titles.
244
-
245
  ### Key Features:
246
  - **Interactive Dashboard**: Visualize job market trends with dynamic charts and graphs.
247
  - **Data Explorer**: Dive deep into individual job listings with advanced filtering options.
248
  - **Real-time Data**: Fetch the latest job data from our Hugging Face dataset.
249
-
250
  ## How to use this application
251
-
252
  ### Dashboard
253
  1. Navigate to the Dashboard using the sidebar.
254
  2. View overall statistics such as total job postings, unique companies, and today's postings.
@@ -257,7 +269,6 @@ def display_about_page():
257
  - Job postings over time
258
  - Top locations for job opportunities
259
  - Most common job titles
260
-
261
  ### Data Explorer
262
  1. Switch to the Data Explorer using the sidebar.
263
  2. Choose between viewing all data or applying filters.
@@ -267,13 +278,10 @@ def display_about_page():
267
  - Job Types
268
  4. Browse the filtered job listings table.
269
  5. Click on job or company links to view more details on the original posting site.
270
-
271
  ## Data Source
272
  This application fetches data from my Private dataset which scrapes data from varoious job hosting portal and the data gets updated daily.
273
-
274
  ## Contact
275
  For questions, feedback, or collaboration opportunities, feel free to reach out:
276
-
277
  - LinkedIn: [Nihar Palem](https://www.linkedin.com/in/nihar-palem-1b955a183/)
278
  """)
279
 
 
82
 
83
  # Drop duplicates and rows with NaT in date_posted
84
  filtered_df = filtered_df.drop_duplicates().dropna(subset=['date_posted'])
85
+ #filtering based on data in 2024
86
+ filtered_df = filtered_df[filtered_df['date_posted'].dt.year=='2024']
87
  # Convert titles to lowercase
88
  filtered_df['title'] = filtered_df['title'].str.lower()
89
 
 
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
 
121
+ def create_time_series(df, time_unit='day'):
122
+ if time_unit == 'month':
123
+ # Group by month and year
124
+ df_by_date = df.groupby(df['date_posted'].dt.to_period('M')).size().reset_index(name='count')
125
+ df_by_date['date_posted'] = df_by_date['date_posted'].dt.to_timestamp()
126
+ else:
127
+ # Keep daily grouping as before
128
+ df_by_date = df.groupby('date_posted').size().reset_index(name='count')
129
+
130
  fig = px.line(df_by_date, x='date_posted', y='count', title="Job Postings Over Time", color_discrete_sequence=['#4e79a7'])
131
  fig.update_layout(
132
  plot_bgcolor='rgba(0,0,0,0)',
 
135
  xaxis_title="Date",
136
  yaxis_title="Number of Job Postings"
137
  )
138
+
139
+ # Adjust x-axis ticks for monthly view
140
+ if time_unit == 'month':
141
+ fig.update_xaxes(
142
+ dtick="M1",
143
+ tickformat="%b %Y"
144
+ )
145
+
146
  return fig
147
 
148
  @st.cache_data
 
176
  st.plotly_chart(fig, use_container_width=True)
177
 
178
  # Job Postings Over Time Chart
179
+ fig_time_series = create_time_series(df,time_unit='month')
180
  st.plotly_chart(fig_time_series, use_container_width=True)
181
 
182
  col3, col4 = st.columns(2)
 
255
  def display_about_page():
256
  st.markdown("""
257
  ## What is this application?
 
258
  The Job Listings Dashboard is a powerful tool designed to provide insights into the job market. It offers a comprehensive view of job postings, allowing users to explore trends, top companies, locations, and job titles.
 
259
  ### Key Features:
260
  - **Interactive Dashboard**: Visualize job market trends with dynamic charts and graphs.
261
  - **Data Explorer**: Dive deep into individual job listings with advanced filtering options.
262
  - **Real-time Data**: Fetch the latest job data from our Hugging Face dataset.
 
263
  ## How to use this application
 
264
  ### Dashboard
265
  1. Navigate to the Dashboard using the sidebar.
266
  2. View overall statistics such as total job postings, unique companies, and today's postings.
 
269
  - Job postings over time
270
  - Top locations for job opportunities
271
  - Most common job titles
 
272
  ### Data Explorer
273
  1. Switch to the Data Explorer using the sidebar.
274
  2. Choose between viewing all data or applying filters.
 
278
  - Job Types
279
  4. Browse the filtered job listings table.
280
  5. Click on job or company links to view more details on the original posting site.
 
281
  ## Data Source
282
  This application fetches data from my Private dataset which scrapes data from varoious job hosting portal and the data gets updated daily.
 
283
  ## Contact
284
  For questions, feedback, or collaboration opportunities, feel free to reach out:
 
285
  - LinkedIn: [Nihar Palem](https://www.linkedin.com/in/nihar-palem-1b955a183/)
286
  """)
287