HR Analytics Dashboard
From HR data, answer:
- Attrition rate
- Attrition by department/job role
- Salary and tenure differences
Analysis pipeline
Section titled “Analysis pipeline”flowchart LR A["Raw HR data
(attrition 0/1)"] --> B["Rate
(overall attrition %)"] B --> C["Segment
(department, role)"] C --> D["Visualize
(attrition by segment)"] D --> E["Conclude
(interventions)"]
Step 1: Load
Section titled “Step 1: Load”import pandas as pd
df = pd.read_csv("data/hr.csv")
print(df.head())Step 2: Attrition rate
Section titled “Step 2: Attrition rate”rate = df["attrition"].mean() # assuming attrition is 0/1
print("Attrition rate:", rate)Step 3: Bar plots by segment
Section titled “Step 3: Bar plots by segment”import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 4))
sns.barplot(data=df, x="department", y="attrition")
plt.title("Attrition rate by department")
plt.xticks(rotation=20)
plt.tight_layout()
plt.show()Step 4: Box plots for numeric features
Section titled “Step 4: Box plots for numeric features”import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(7, 4))
sns.boxplot(data=df, x="attrition", y="salary")
plt.title("Salary vs attrition")
plt.tight_layout()
plt.show()Visualize it
Section titled “Visualize it”Deliverable
Section titled “Deliverable”A dashboard should include:
- Attrition KPI
- Top segments with high attrition
- Suggested interventions (training, compensation, career path)
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – Overall attrition rate
Section titled “Exercise 1 – Overall attrition rate”Exercise 2 – Attrition by department
Section titled “Exercise 2 – Attrition by department”Exercise 3 – Two-way attrition pivot table
Section titled “Exercise 3 – Two-way attrition pivot table”pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading