Photo by Jannis Lucas on Unsplash.
Every year, American high school students take SATs, which are standardized tests intended to measure literacy, numeracy, and writing skills. There are three sections - reading, math, and writing, each with a maximum score of 800 points. These tests are extremely important for students and colleges, as they play a pivotal role in the admissions process.
Analyzing the performance of schools is important for a variety of stakeholders, including policy and education professionals, researchers, government, and even parents considering which school their children should attend.
You have been provided with a dataset called schools.csv
, which is previewed below.
You have been tasked with answering three key questions about New York City (NYC) public school SAT performance.
# Re-run this cell
import pandas as pd
import numpy as np
# Read in the data
schools = pd.read_csv("schools.csv")
# Preview the data
schools.head()
Now we'll filter the schools whose results are at least 80% of the maximum possible score in average_math.
# Filtering the dataset to only the greater 80% schools of the maximum possible score
best_math_schools = schools.loc[schools['average_math'] >= 640, ['school_name','average_math']].sort_values('average_math', ascending = False)
# Preview the best schools in math
best_math_schools.head()
Let's compute the total SAT for each school to get the top 10.
# create a variable that calculates de SAT as the sum of all scores
schools['total_SAT'] = schools.loc[:,['average_math', 'average_reading', 'average_writing']].apply(sum, axis = 'columns')
schools.head()
# Identify the top 10 performing schools based on scores across the three SAT sections
top_10_schools = schools.loc[:,['school_name', 'total_SAT']].sort_values('total_SAT', ascending = False)[:10]
# Top 10 schools
display(top_10_schools)
Now, let's dive into the NYC schools
# calculating the standard deviation for the SAT in each school
sat_by_borough = schools.groupby('borough')['total_SAT'].agg([np.count_nonzero, np.mean, np.std])
# renaming column labels
sat_by_borough = sat_by_borough.rename(columns = {'count_nonzero': 'num_schools', 'mean': 'average_SAT', 'std': 'std_SAT'})
print(sat_by_borough)
# NYC borough with the largest standard deviation for "total_SAT"
largest_std_dev = sat_by_borough.sort_values('std_SAT', ascending = False)[:1].round(2)
print(largest_std_dev)