SAMANTUS Python for Data Analytics — Complete Training Manual CAPSTONE PROJECT 09
← Back to Course Index

Hospital Data Analysis


On This Page

Capstone Project 9: Hospital Data Analysis


C9.1  Project Overview

This project analyzes hospital patient visit data to understand department load and patient wait times, supporting better staffing and resource planning.

C9.2  Business Problem

Hospital administration wants to know which departments handle the most patient volume, and whether wait times are within an acceptable range, to plan staffing more effectively.

C9.3  Dataset Description

ColumnDescription
patient_idUnique patient identifier
departmentHospital department visited
wait_time_minutesTime waited before being seen
visit_dateDate of the visit

Sample scope: 300 patient visit records from the last month.

C9.4  Objectives


C9.5  Step-by-Step Solution

C9.6  Complete Python Code

► hospital_analysis.py
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv("hospital_visits.csv")
df = df.dropna(subset=['wait_time_minutes'])

visits_by_dept = df['department'].value_counts()
print("Patient Visits by Department:\n", visits_by_dept)

avg_wait_by_dept = df.groupby('department')['wait_time_minutes'].mean().sort_values(ascending=False)
print("Average Wait Time by Department:\n", avg_wait_by_dept.round(1))

plt.hist(df["wait_time_minutes"], bins=20)
plt.title("Wait Time Distribution")
plt.savefig("wait_hist.png")

C9.7  Expected Output

Output
Patient Visits by Department:
General   550
Pediatrics  410
Cardiology  320
Orthopedics  280
Neurology  190

C9.8  Visualizations

Figure C9.1 — Monthly patient visits by department.
Figure C9.1 — Monthly patient visits by department.
Figure C9.2 — Distribution of patient wait times across all departments.
Figure C9.2 — Distribution of patient wait times across all departments.

C9.9  Key Insights

C9.10  Business Recommendations