Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Calculate and Visualize Turnover | Introduction to People Analytics with Python
Python for People Analytics
Section 1. Chapitre 5
single

single

bookChallenge: Calculate and Visualize Turnover

Glissez pour afficher le menu

Understanding employee turnover is vital in people analytics because it provides insight into workforce stability and organizational health. Turnover rate measures the proportion of employees who leave an organization within a specific period, typically a year, relative to the average number of employees. This metric helps HR professionals identify trends, forecast staffing needs, and address potential issues related to retention. Visualizing turnover data makes patterns more accessible and actionable, supporting data-driven decision-making.

123456789101112131415161718
# Lists of employee names current_employees = ["Alice", "Bob", "Charlie", "David", "Eva", "Frank", "Grace"] former_employees = ["Helen", "Ian", "Jack"] # Calculate turnover rate total_employees = len(current_employees) + len(former_employees) turnover_rate = (len(former_employees) / total_employees) * 100 # Basic bar chart setup import matplotlib.pyplot as plt categories = ["Current Employees", "Former Employees"] counts = [len(current_employees), len(former_employees)] plt.bar(categories, counts, color=["skyblue", "salmon"]) plt.ylabel("Number of Employees") plt.title("Employee Status Overview") plt.show()
copy

When creating HR reports, annotating your charts with key metrics—such as the turnover rate—adds valuable context. To annotate a bar chart in matplotlib, you can use the plt.text() function to display the turnover rate directly above the bars or in the title. This helps stakeholders quickly interpret the results and understand the scale of workforce changes. Interpreting turnover data involves considering not just the percentage, but also the underlying causes and potential impact on the organization. High turnover may signal issues with employee satisfaction, culture, or management practices, while low turnover could indicate stability or, in some cases, stagnation.

Tâche

Swipe to start coding

Implement a Python function that calculates the turnover rate from two lists and visualizes the result.

  • Calculate the total number of employees by summing the lengths of current_employees and former_employees.
  • Compute the turnover rate as the percentage of former_employees out of the total number of employees.
  • Create a bar chart with categories for current and former employees, using the counts from each list.
  • Annotate the bar chart with the calculated turnover rate.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 5
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt