-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobs.py
86 lines (72 loc) · 2.28 KB
/
jobs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import pandas as pd
import plotly.graph_objects as go
# Load the CSV data
file_path = 'jobs.csv'
df = pd.read_csv(file_path)
# Convert date columns to datetime
df['Date Applied'] = pd.to_datetime(df['Date Applied'])
df['Date Responded'] = pd.to_datetime(df['Date Responded'], errors='coerce')
# Calculate the time to hear back
df['Time to Hear Back (days)'] = (df['Date Responded'] - df['Date Applied']).dt.days
# Prepare data for the Sankey diagram
sources = []
targets = []
values = []
# Status counts
status_counts = df['Status'].value_counts()
rejected_count = status_counts.get('Rejected', 0)
interview_count = status_counts.get('Interview', 0)
no_answer_count = status_counts.get('No Answer', 0)
# Total applications
total_applications = len(df)
sources.append('Total Applications')
targets.append('Rejected')
values.append(rejected_count)
sources.append('Total Applications')
targets.append('Interview')
values.append(interview_count)
sources.append('Total Applications')
targets.append('No Answer')
values.append(no_answer_count)
# Outcome counts for interviews
if interview_count > 0:
outcome_counts = df[df['Status'] == 'Interview']['Interview'].value_counts()
for outcome, count in outcome_counts.items():
sources.append('Interview')
targets.append(outcome)
values.append(count)
# Average time to hear back
avg_time_to_hear_back = df['Time to Hear Back (days)'].mean()
# Create the labels and indices for Sankey diagram
unique_labels = list(set(sources + targets))
label_indices = {label: i for i, label in enumerate(unique_labels)}
# Create the Sankey diagram
sankey = go.Sankey(
node=dict(
pad=15,
thickness=20,
line=dict(color="black", width=0.5),
label=unique_labels,
),
link=dict(
source=[label_indices[src] for src in sources],
target=[label_indices[tgt] for tgt in targets],
value=values
)
)
# Create the figure and add annotation
fig = go.Figure(data=[sankey])
fig.update_layout(
title_text="2024 Job Hunt",
font_size=10,
annotations=[
dict(
x=0.5, y=-0.1,
xref='paper', yref='paper',
text=f'Average time to hear back: {avg_time_to_hear_back:.1f} days',
showarrow=False,
font=dict(size=12)
)
]
)
fig.show()