Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import pandas as pd
|
|
| 2 |
import streamlit as st
|
| 3 |
import joblib
|
| 4 |
import time
|
| 5 |
-
import os
|
| 6 |
import plotly.graph_objects as go
|
| 7 |
import numpy as np
|
| 8 |
from datetime import datetime
|
|
@@ -282,6 +281,7 @@ def stock_chart(data, company_name):
|
|
| 282 |
st.error(f"Error generating stock chart: {str(e)}")
|
| 283 |
st.write("Debug info - data received:", data)
|
| 284 |
return go.Figure() # Return empty figure on error
|
|
|
|
| 285 |
# =============================================
|
| 286 |
# JOB POSITIONS DATA
|
| 287 |
# =============================================
|
|
@@ -396,7 +396,6 @@ def main():
|
|
| 396 |
""", unsafe_allow_html=True)
|
| 397 |
|
| 398 |
st.markdown('<div class="divider"></div>', unsafe_allow_html=True)
|
| 399 |
-
|
| 400 |
|
| 401 |
# Sidebar with dark teal background
|
| 402 |
with st.sidebar:
|
|
@@ -471,14 +470,14 @@ def main():
|
|
| 471 |
}
|
| 472 |
LevelDescription = career_to_level_description.get(CareerLevel, [None])[0]
|
| 473 |
|
| 474 |
-
df_forecast=pd.read_excel('forecast.xlsx')
|
| 475 |
-
if
|
| 476 |
current_date = datetime.now()
|
| 477 |
date = f'{current_date.month:02d}.2025'
|
| 478 |
NumberOfPositions = df_forecast.loc[df_forecast["Business Titles"] == BusinessTitle, date].values[0]
|
| 479 |
else:
|
| 480 |
df = pd.read_csv('cleaned_job_salaries.csv')
|
| 481 |
-
NumberOfPositions=df.loc[df["Business Title"] == BusinessTitle]['# Of Positions'].mean()
|
| 482 |
|
| 483 |
if st.button('Predict Salary', use_container_width=True):
|
| 484 |
st.session_state.predict_clicked = True
|
|
@@ -516,13 +515,26 @@ def main():
|
|
| 516 |
|
| 517 |
# Results section
|
| 518 |
st.markdown("## Prediction Results")
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
|
| 527 |
# Job details
|
| 528 |
st.markdown("### Job Summary")
|
|
@@ -534,7 +546,46 @@ def main():
|
|
| 534 |
with col3:
|
| 535 |
company_metric("Education Level", RequiredDegree)
|
| 536 |
|
| 537 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
st.markdown("""
|
| 539 |
<style>
|
| 540 |
.footer {
|
|
@@ -552,9 +603,7 @@ def main():
|
|
| 552 |
<hr style="border: 0.5px solid #e2e8f0;">
|
| 553 |
Created with ❤️ by Senasu & Sude
|
| 554 |
</div>
|
| 555 |
-
""", unsafe_allow_html=True)
|
| 556 |
-
|
| 557 |
-
|
| 558 |
|
| 559 |
if __name__ == '__main__':
|
| 560 |
main()
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import joblib
|
| 4 |
import time
|
|
|
|
| 5 |
import plotly.graph_objects as go
|
| 6 |
import numpy as np
|
| 7 |
from datetime import datetime
|
|
|
|
| 281 |
st.error(f"Error generating stock chart: {str(e)}")
|
| 282 |
st.write("Debug info - data received:", data)
|
| 283 |
return go.Figure() # Return empty figure on error
|
| 284 |
+
|
| 285 |
# =============================================
|
| 286 |
# JOB POSITIONS DATA
|
| 287 |
# =============================================
|
|
|
|
| 396 |
""", unsafe_allow_html=True)
|
| 397 |
|
| 398 |
st.markdown('<div class="divider"></div>', unsafe_allow_html=True)
|
|
|
|
| 399 |
|
| 400 |
# Sidebar with dark teal background
|
| 401 |
with st.sidebar:
|
|
|
|
| 470 |
}
|
| 471 |
LevelDescription = career_to_level_description.get(CareerLevel, [None])[0]
|
| 472 |
|
| 473 |
+
df_forecast = pd.read_excel('forecast.xlsx')
|
| 474 |
+
if BusinessTitle in df_forecast["Business Titles"].values:
|
| 475 |
current_date = datetime.now()
|
| 476 |
date = f'{current_date.month:02d}.2025'
|
| 477 |
NumberOfPositions = df_forecast.loc[df_forecast["Business Titles"] == BusinessTitle, date].values[0]
|
| 478 |
else:
|
| 479 |
df = pd.read_csv('cleaned_job_salaries.csv')
|
| 480 |
+
NumberOfPositions = df.loc[df["Business Title"] == BusinessTitle]['# Of Positions'].mean()
|
| 481 |
|
| 482 |
if st.button('Predict Salary', use_container_width=True):
|
| 483 |
st.session_state.predict_clicked = True
|
|
|
|
| 515 |
|
| 516 |
# Results section
|
| 517 |
st.markdown("## Prediction Results")
|
| 518 |
+
|
| 519 |
+
# Check if NumberOfPositions came from forecast and is not zero
|
| 520 |
+
show_positions = (BusinessTitle in df_forecast["Business Titles"].values) and (NumberOfPositions != 0)
|
| 521 |
+
|
| 522 |
+
if show_positions:
|
| 523 |
+
prediction_card(
|
| 524 |
+
"Annual Salary",
|
| 525 |
+
predicted_salary,
|
| 526 |
+
f"{BusinessTitle} | {NumberOfPositions:.0f} positions available",
|
| 527 |
+
CareerLevel,
|
| 528 |
+
"💵"
|
| 529 |
+
)
|
| 530 |
+
else:
|
| 531 |
+
prediction_card(
|
| 532 |
+
"Annual Salary",
|
| 533 |
+
predicted_salary,
|
| 534 |
+
BusinessTitle,
|
| 535 |
+
CareerLevel,
|
| 536 |
+
"💵"
|
| 537 |
+
)
|
| 538 |
|
| 539 |
# Job details
|
| 540 |
st.markdown("### Job Summary")
|
|
|
|
| 546 |
with col3:
|
| 547 |
company_metric("Education Level", RequiredDegree)
|
| 548 |
|
| 549 |
+
# Market analysis section
|
| 550 |
+
if BusinessTitle in job_positions:
|
| 551 |
+
st.markdown("## Market Intelligence")
|
| 552 |
+
st.markdown("""
|
| 553 |
+
<p style="color: #64748b;">
|
| 554 |
+
Below you'll find financial performance data for top companies hiring this position
|
| 555 |
+
</p>
|
| 556 |
+
""", unsafe_allow_html=True)
|
| 557 |
+
companies = job_positions[BusinessTitle]
|
| 558 |
+
for i in range(1, 4): # Show first 3 companies (keys 1, 2, 3)
|
| 559 |
+
company_name = companies[i]
|
| 560 |
+
with st.expander(f"{company_name} Market Analysis", expanded=(i==1)):
|
| 561 |
+
try:
|
| 562 |
+
data = pd.read_csv(f'Finance Data/{company_name}.csv', index_col=0, header=[0, 1])
|
| 563 |
+
close_data = data['Close'].copy()
|
| 564 |
+
close_data = pd.DataFrame(close_data)
|
| 565 |
+
close_data.index = pd.to_datetime(close_data.index)
|
| 566 |
+
close_data.columns = ['Close']
|
| 567 |
+
|
| 568 |
+
fig = stock_chart(close_data, company_name)
|
| 569 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 570 |
+
|
| 571 |
+
# Company metrics
|
| 572 |
+
current_price = close_data['Close'].iloc[-1]
|
| 573 |
+
monthly_change = ((current_price - close_data['Close'].iloc[-30]) / close_data['Close'].iloc[-30]) * 100
|
| 574 |
+
volatility = (close_data['Close'].std() / close_data['Close'].mean()) * 100
|
| 575 |
+
|
| 576 |
+
cols = st.columns(3)
|
| 577 |
+
with cols[0]:
|
| 578 |
+
company_metric("Current Price", f"${current_price:.2f}")
|
| 579 |
+
with cols[1]:
|
| 580 |
+
company_metric("30-Day Change", f"{monthly_change:.2f}%", monthly_change)
|
| 581 |
+
with cols[2]:
|
| 582 |
+
company_metric("Volatility", f"{volatility:.2f}%")
|
| 583 |
+
|
| 584 |
+
except FileNotFoundError:
|
| 585 |
+
st.error(f"Data not available for {company_name}")
|
| 586 |
+
except Exception as e:
|
| 587 |
+
st.error(f"Error loading data for {company_name}: {str(e)}")
|
| 588 |
+
|
| 589 |
st.markdown("""
|
| 590 |
<style>
|
| 591 |
.footer {
|
|
|
|
| 603 |
<hr style="border: 0.5px solid #e2e8f0;">
|
| 604 |
Created with ❤️ by Senasu & Sude
|
| 605 |
</div>
|
| 606 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
| 607 |
|
| 608 |
if __name__ == '__main__':
|
| 609 |
main()
|