In [1]:
import pandas as pd 
import plotly.express as px 
import plotly.io as pio
import sqlite3

pio.renderers.default = "iframe"
csv_path = "candidates.csv"
df= pd.read_csv(csv_path, sep= ';')

Exploratory Data Analysis

In [2]:
df.head()
Out[2]:
First Name Last Name Email Application Date Country YOE Seniority Technology Code Challenge Score Technical Interview Score
0 Bernadette Langworth [email protected] 2021-02-26 Norway 2 Intern Data Engineer 3 3
1 Camryn Reynolds [email protected] 2021-09-09 Panama 10 Intern Data Engineer 2 10
2 Larue Spinka [email protected] 2020-04-14 Belarus 4 Mid-Level Client Success 10 9
3 Arch Spinka [email protected] 2020-10-01 Eritrea 25 Trainee QA Manual 7 1
4 Larue Altenwerth [email protected] 2020-05-20 Myanmar 13 Mid-Level Social Media Community Management 9 7
In [3]:
df.shape
Out[3]:
(50000, 10)
In [4]:
df.info()
<class 'pandas.DataFrame'>
RangeIndex: 50000 entries, 0 to 49999
Data columns (total 10 columns):
 #   Column                     Non-Null Count  Dtype
---  ------                     --------------  -----
 0   First Name                 50000 non-null  str  
 1   Last Name                  50000 non-null  str  
 2   Email                      50000 non-null  str  
 3   Application Date           50000 non-null  str  
 4   Country                    50000 non-null  str  
 5   YOE                        50000 non-null  int64
 6   Seniority                  50000 non-null  str  
 7   Technology                 50000 non-null  str  
 8   Code Challenge Score       50000 non-null  int64
 9   Technical Interview Score  50000 non-null  int64
dtypes: int64(3), str(7)
memory usage: 7.6 MB
In [5]:
df.isnull().sum()
Out[5]:
First Name                   0
Last Name                    0
Email                        0
Application Date             0
Country                      0
YOE                          0
Seniority                    0
Technology                   0
Code Challenge Score         0
Technical Interview Score    0
dtype: int64
In [6]:
df.duplicated().sum()
Out[6]:
0
In [7]:
df["Seniority"].value_counts()
Out[7]:
Seniority
Intern       7255
Mid-Level    7253
Trainee      7183
Junior       7100
Architect    7079
Lead         7071
Senior       7059
Name: count, dtype: int64
In [8]:
df["Technology"].value_counts()
Out[8]:
Technology
Game Development                           3818
DevOps                                     3808
Social Media Community Management          2028
System Administration                      2014
Mulesoft                                   1973
Development - Backend                      1965
Development - FullStack                    1961
Adobe Experience Manager                   1954
Data Engineer                              1951
Security                                   1936
Development - CMS Frontend                 1934
Business Intelligence                      1934
Database Administration                    1933
Client Success                             1927
Design                                     1906
QA Manual                                  1902
Technical Writing                          1901
QA Automation                              1892
Sales                                      1890
Development - Frontend                     1887
Development - CMS Backend                  1882
Business Analytics / Project Management    1878
Salesforce                                 1874
Security Compliance                        1852
Name: count, dtype: int64
In [9]:
df["Code Challenge Score"].value_counts().sort_index()
Out[9]:
Code Challenge Score
0     4502
1     4590
2     4579
3     4678
4     4521
5     4479
6     4419
7     4506
8     4619
9     4519
10    4588
Name: count, dtype: int64
In [10]:
df["Technical Interview Score"].value_counts().sort_index()
Out[10]:
Technical Interview Score
0     4539
1     4588
2     4500
3     4528
4     4578
5     4527
6     4471
7     4578
8     4555
9     4597
10    4539
Name: count, dtype: int64

Transformation

In [11]:
HIRE_THRESHOLD=7
df["Application Date"]= pd.to_datetime(df["Application Date"])
df["Year"]= df["Application Date"].dt.year

df["HIRED"]= (
    (df["Code Challenge Score"] >= HIRE_THRESHOLD)
    & (df["Technical Interview Score"] >= HIRE_THRESHOLD)
).astype(int)
In [12]:
df[["Application Date", "Year", "Code Challenge Score", "Technical Interview Score", "HIRED"]].head()
Out[12]:
Application Date Year Code Challenge Score Technical Interview Score HIRED
0 2021-02-26 2021 3 3 0
1 2021-09-09 2021 2 10 0
2 2020-04-14 2020 10 9 1
3 2020-10-01 2020 7 1 0
4 2020-05-20 2020 9 7 1

Data Base Migration

In [13]:
conn=sqlite3.connect("candidates.db")
In [14]:
df.to_sql(
    "candidates",
    conn,
    if_exists= "replace",
    index = False,
    method = "multi",
    chunksize= 1000
)
print (f"Loaded {len(df)} records into 'candidates'")
Loaded 50000 records into 'candidates'
In [15]:
query= """
SELECT HIRED, COUNT (*) AS TOTAL 
FROM candidates
GROUP BY HIRED
"""
pd.read_sql_query(query,conn)
Out[15]:
HIRED TOTAL
0 0 43302
1 1 6698

Visualizations

In [16]:
query= """
SELECT Technology, COUNT (*) AS Hires
FROM candidates
WHERE HIRED = 1 
GROUP BY Technology
ORDER BY Hires DESC
"""
hires_by_technology= pd.read_sql_query(query, conn)

fig = px.pie(
    hires_by_technology,
    values="Hires",
    names="Technology",
    title="Hires by Technology"
)
fig.show()
    
In [17]:
query= """
SELECT Year, COUNT (*) AS Hires
FROM candidates 
WHERE HIRED = 1
GROUP BY Year
ORDER BY Year
"""

hires_by_year= pd.read_sql_query(query, conn)

fig= px.bar(
    hires_by_year,
    x="Hires",
    y="Year",
    orientation= "h", 
    title= "Hires by Year",
)
fig.show()
In [18]:
query= """
SELECT Seniority, COUNT (*) AS Hires
FROM candidates
WHERE HIRED = 1
GROUP BY Seniority
ORDER BY Hires DESC
"""

hires_by_seniority= pd.read_sql_query(query,conn)

fig= px.bar(
    hires_by_seniority,
    x="Seniority",
    y="Hires",
    title= "Hires by Seniority"
)
fig.show()
In [19]:
query = """
SELECT Year, Country, COUNT (*) AS Hires
FROM candidates
WHERE HIRED = 1
AND Country IN('United States of America', 'Brazil', 'Colombia', 'Ecuador')
GROUP BY Year, Country
ORDER BY Year
"""
hires_by_country = pd.read_sql_query(query,conn)
hires_by_country["Year"] = hires_by_country["Year"].astype(str)

fig= px.line(
    hires_by_country,
    x="Year",
    y="Hires",
    color="Country",
    markers = True,
    title="Hires by Country Over the Years"
)
fig.show()
    
In [ ]: