Skip to content
0

📖 Background

You work for an international HR consultancy helping companies attract and retain top talent in the competitive tech industry. As part of your services, you provide clients with insights into industry salary trends to ensure they remain competitive in hiring and compensation practices.

Your team wants to use a data-driven approach to analyse how various factors—such as job role, experience level, remote work, and company size—impact salaries globally. By understanding these trends, you can advise clients on offering competitive packages to attract the best talent.

In this competition, you’ll explore and visualise salary data from thousands of employees worldwide. f you're tackling the advanced level, you'll go a step further—building predictive models to uncover key salary drivers and providing insights on how to enhance future data collection.

💾 The data

The data comes from a survey hosted by an HR consultancy, available in 'salaries.csv'.

Each row represents a single employee's salary record for a given year:
  • work_year - The year the salary was paid.
  • experience_level - Employee experience level:
    • EN: Entry-level / Junior
    • MI: Mid-level / Intermediate
    • SE: Senior / Expert
    • EX: Executive / Director
  • employment_type - Employment type:
    • PT: Part-time
    • FT: Full-time
    • CT: Contract
    • FL: Freelance
  • job_title - The job title during the year.
  • salary - Gross salary paid (in local currency).
  • salary_currency - Salary currency (ISO 4217 code).
  • salary_in_usd - Salary converted to USD using average yearly FX rate.
  • employee_residence - Employee's primary country of residence (ISO 3166 code).
  • remote_ratio - Percentage of remote work:
    • 0: No remote work (<20%)
    • 50: Hybrid (50%)
    • 100: Fully remote (>80%)
  • company_location - Employer's main office location (ISO 3166 code).
  • company_size - Company size:
    • S: Small (<50 employees)
    • M: Medium (50–250 employees)
    • L: Large (>250 employees)

⌛️ Time is ticking. Good luck!

import pandas as pd
import matplotlib.pyplot as plt

salaries_df = pd.read_csv('salaries.csv')
salaries_df

Create a bar chart displaying the top 5 job titles with the highest average salary (in USD).

mean_salaries_df = salaries_df.groupby('job_title')['salary'].mean().round(2)
top5 = mean_salaries_df.nlargest(5).reset_index()
print(top5)
plt.figure(figsize=(17,6))
plt.bar(top5['job_title'], top5['salary'], color='purple')
plt.title('Top 5 job titles with the highest average salary (in USD)')
plt.xlabel('Job title')
plt.ylabel('Average salary')
plt.show()

Compare the average salaries for employees working remotely 100%, 50%, and 0%. What patterns or trends do you observe?

salaries_df.groupby('remote_ratio')['salary'].mean().round(2)

We observe that employees working remotely 50% earn more on average than employees working remotely at 100% and 0%.

Visualise the salary distribution (in USD) across company sizes (S, M, L). Which company size offers the highest average salary?

salaries_bycompany_df = salaries_df.groupby('company_size')['salary'].mean().round(2)
salaries_bycompany_df = salaries_bycompany_df.reset_index()
company_size_order = ['S','M','L']
salaries_bycompany_df['company_size'] = pd.Categorical(salaries_bycompany_df['company_size'], categories=company_size_order, ordered=True)
salaries_bycompany_df = salaries_bycompany_df.sort_values('company_size')
salaries_bycompany_df
salaries_bycompany_df = salaries_bycompany_df.reset_index()
plt.figure(figsize=(17,6))
plt.bar(salaries_bycompany_df['company_size'], salaries_bycompany_df['salary'], color='skyblue')
plt.title('Salary distribution across company sizes')
plt.xlabel('Company size')
plt.ylabel('Average salary')
plt.show()

The small company, less than 50 employees, offers greater salary than large and medium company.