Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Analyze and Visualize Diversity | Analyzing Workforce Trends
Python for People Analytics
Osio 2. Luku 5
single

single

bookChallenge: Analyze and Visualize Diversity

Pyyhkäise näyttääksesi valikon

Understanding diversity metrics is central to People Analytics. These metrics—such as gender ratio and ethnic distribution—enable you to assess representation and inclusivity within the workforce. By quantifying diversity, organizations can identify imbalances, track progress toward equity goals, and inform decision-making that fosters a more inclusive environment.

123456789101112131415161718192021222324
import pandas as pd import matplotlib.pyplot as plt # Example DataFrame of employee demographics data = { "EmployeeID": [101, 102, 103, 104, 105, 106, 107, 108], "Gender": ["Female", "Male", "Female", "Male", "Female", "Female", "Male", "Male"], "Age": [34, 27, 29, 41, 36, 28, 32, 38], "Ethnicity": ["Hispanic", "White", "Black", "Asian", "White", "Black", "Asian", "Hispanic"] } df = pd.DataFrame(data) # Basic matplotlib chart setup plt.figure(figsize=(6,4)) plt.bar(df["Gender"].value_counts().index, df["Gender"].value_counts().values) plt.title("Employee Count by Gender") plt.xlabel("Gender") plt.ylabel("Count") plt.show() plt.figure(figsize=(6,6)) plt.pie(df["Ethnicity"].value_counts().values, labels=df["Ethnicity"].value_counts().index, autopct='%1.1f%%') plt.title("Ethnicity Distribution") plt.show()
copy

When interpreting diversity visualizations, focus on the proportions and representation of each group rather than just raw counts. Bar charts can quickly reveal gender imbalances, while pie charts highlight the presence or absence of particular ethnicities. Communicating these results effectively means translating visuals into actionable insights—such as noting underrepresented groups or shifts in workforce composition—to guide leadership in setting and evaluating diversity initiatives.

Tehtävä

Swipe to start coding

Implement a Python script that analyzes and visualizes diversity in a hardcoded employee demographic DataFrame.

  • Calculate the gender ratio as the proportion of each gender in the workforce.
  • Calculate the proportion of each ethnicity present in the data.
  • Create a bar chart showing the count of employees by gender.
  • Create a pie chart showing the distribution of ethnicities.
  • Summarize your findings as comments within your code.

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 2. Luku 5
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

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

some-alt