single
Challenge: Calculate and Visualize Turnover
Swipe to show 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()
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.
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_employeesandformer_employees. - Compute the turnover rate as the percentage of
former_employeesout 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
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat