Mini Project: Analysis of Students’ Performance
using Pandas and Matplotlib
Objective:
To analyze students’ performance data and visualize insights such as average scores, gender-wise
comparison, and correlation between subjects.
Dataset Used:
Students Performance Dataset (Kaggle):
[Link]
Columns: gender, race/ethnicity, parental level of education, lunch, test preparation course, math
score, reading score, writing score
1. Import Libraries
import pandas as pd
import [Link] as plt
2. Load Dataset
df = pd.read_csv("[Link]")
print([Link]())
3. Basic Information
print([Link]())
print([Link]())
print([Link]().sum())
4. Data Analysis with Pandas
# Average scores
avg_scores = df[['math score', 'reading score', 'writing score']].mean()
# Gender-wise average
gender_avg = [Link]('gender')[['math score', 'reading score', 'writing score']].mean()
# Test preparation course impact
prep_avg = [Link]('test preparation course')[['math score', 'reading score', 'writing score']].me
# Add total and average score columns
df['total_score'] = df['math score'] + df['reading score'] + df['writing score']
df['average_score'] = df['total_score'] / 3
5. Visualization with Matplotlib
# Bar Chart – Average Marks by Gender
gender_avg.plot(kind='bar', figsize=(7,5))
[Link]('Average Marks by Gender')
[Link]('Average Score')
[Link]('Gender')
[Link](loc='lower right')
[Link]()
# Box Plot – Distribution of Scores by Gender
[Link](column=['math score', 'reading score', 'writing score'], by='gender', figsize=(8,6))
[Link]('Score Distribution by Gender')
[Link]()
# Histogram – Total Score Distribution
[Link](df['total_score'], bins=10, color='skyblue', edgecolor='black')
[Link]('Distribution of Total Scores')
[Link]('Total Score')
[Link]('Number of Students')
[Link]()
# Pie Chart – Test Preparation Course
course_counts = df['test preparation course'].value_counts()
course_counts.plot(kind='pie', autopct='%1.1f%%', startangle=90)
[Link]('Test Preparation Course Status')
[Link]('')
[Link]()
# Correlation Heatmap
import seaborn as sns
[Link](figsize=(6,5))
[Link](df[['math score','reading score','writing score']].corr(), annot=True, cmap='coolwarm')
[Link]('Correlation between Subjects')
[Link]()
Conclusion:
- Female students scored higher in reading and writing, while males performed slightly better in
math.
- Students who completed the test preparation course achieved higher average marks.
- There is a strong positive correlation between reading and writing scores.