Case Study Assignment 5
Case Study Assignment 5
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv('students_data.csv')
highest_marks = data.groupby('Major')['SGPA'].max()
plt.figure(figsize=(8, 6))
plt.pie(highest_marks, labels=highest_marks.index, autopct='%1.1f%%', startangle=140)
plt.show()
Number of students in each department
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv('students_data.csv')
department_counts = data['Major'].value_counts()
plt.figure(figsize=(8, 6))
plt.pie(department_counts, labels=department_counts.index, autopct='%1.1f%%',
startangle=140)
plt.show()
Comparing how India won against its best opponent in cricket
import matplotlib.pyplot as plt
with open('cricketscore.txt', 'r') as file:
lines = file.readlines()[1:]
highest_score = 0
best_opponent = ""
opponent_score = 0
for line in lines:
parts = line.strip().split(',')
if len(parts) < 5:
continue
try:
score = int(parts[4].split('/')[0].split()[-1])
if score > highest_score:
highest_score = score
best_opponent = parts[2]
opponent_score = highest_score * 0.75 # Assuming opponent scored 75% of India’s
runs
except ValueError:
continue
labels = [f'India ({highest_score})', f'{best_opponent} (~{int(opponent_score)})']
sizes = [highest_score, opponent_score]
plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
plt.show()