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

single

bookChallenge: Calculate and Visualize Turnover

Pyyhkäise näyttääksesi valikon

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.

Tehtävä

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 5
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt