Skip to content

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

# Read in the data
schools = pd.read_csv("schools.csv")

# Preview the data
schools.head()

# '''Which NYC schools have the best math results?'''

# Selects schools that have at least 80% of the Max 800 math score:
best_math_schools = schools[schools['average_math'] > (0.8*800)]
# Keeping only school name and math score, sorting values in descending:
best_math_schools = best_math_schools[['school_name', 'average_math']].sort_values('average_math', ascending=False)
#print(best_math_schools.head(10))

# '''What are the top 10 performing schools based on the combined SAT scores?'''

# Creates and calculates total SAT score as sum of Math, Reading, and Writing:
schools['total_SAT'] = schools['average_math'] + schools['average_reading'] + schools['average_writing']
top_10_schools = schools.sort_values('total_SAT', ascending=False)[0:10][['school_name', 'total_SAT']]
#print(top_10_schools)

# '''Which single borough has the largest standard deviation in the combined SAT score?'''

# Calculates standard deviation of SAT per NY borough
SAT_borough_STD = schools.groupby('borough')['total_SAT'].std()
print(SAT_borough_STD)
# Identifies name and value of the NY borough with highest STA standard deviation...:
max_STD_borough = SAT_borough_STD.idxmax()
max_STD_value = SAT_borough_STD.max()
print(f"Borough with the largest standard deviation in combined SAT score: {max_STD_borough} with a standard deviation of {max_STD_value}")
# ...and record them into largest_std_dev df
largest_std_dev = pd.DataFrame({'borough': [max_STD_borough], 'std_SAT': [max_STD_value]})
# Subset the schools from the NY borough with highest SAT standard deviation:
bor_schools = schools[schools['borough'] == max_STD_borough]
# Adds number of schools and average SAT to the df largest_std_dev:
largest_std_dev['num_schools'] = len(bor_schools)
largest_std_dev['average_SAT'] = bor_schools['total_SAT'].mean()
# Rounds all values of df largest_std_dev to 2 decimals
largest_std_dev = round(largest_std_dev, 2)