Skip to content
Competition - Certification competition
Show off your SQL expertise by earning a Certification
🎓 Step 1: Get Certified!
📝 Step 2: Explain your choice of metrics
Your boss was impressed with the analysis work that you did and shared it with the team leaders. They have no background of working with data and don’t understand what you mean by average, or why you picked the approach you did to calculate it.
Can you explain to the team leaders, in no more than 200 words, how you calculated the average, what an average means and the different approaches to averages, and why you picked this summary?
- An average is like finding a typical value in a group of numbers. To calculate it, we add up all the numbers and divide by how many numbers there are. For example, if we are looking at scores on a test: 90,80,92. The average would be (90+80+92)/3. Here 3 is the number of scores. So, the average is 87.33. Finding the average score tells us roughly how well everyone did overall.
- To find the average score in each subject, we first collect all the scores for Math, Science, and English. Then, we add up these scores separately for each subject. After that, we divide the total score by the number of students who took that subject. This gives us the average score for each subject. We use Python with a special tool called pandas to do this calculation efficiently. The result is a list showing the average score for Math, Science, and English. This helps us understand how students are performing on average in each subject.
⏳ Time is ticking. Good Luck!
import pandas as pd
# Create a DataFrame with the provided data
data = {
'Student_ID': [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],
'Name': ['Alice', 'Alice', 'Alice', 'Bob', 'Bob', 'Bob', 'Charlie', 'Charlie', 'Charlie', 'David', 'David', 'David', 'Emma', 'Emma', 'Emma'],
'Subject': ['Math', 'Science', 'English', 'Math', 'Science', 'English', 'Math', 'Science', 'English', 'Math', 'Science', 'English', 'Math', 'Science', 'English'],
'Score': [85, 90, 88, 70, 75, 80, 92, 88, 90, 78, 82, 85, 95, 94, 92]
}
df = pd.DataFrame(data)
# Calculate average score by subject
average_scores = df.groupby('Subject')['Score'].mean().reset_index()
print(average_scores)