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.

import pandas as pd

schools = pd.read_csv("schools.csv")

# Show all
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
print(schools)
Hidden output
# Start coding here...

# Q1.    Finding schools with the best math scores
# Subset the data to find which schools have the 80% math scores
best_math_schools = schools[schools['average_math'] >= 640][['school_name', 'average_math']]

# Sort by average_math in descending order
best_math_schools = best_math_schools.sort_values(by='average_math', ascending=False)

# Display the results
print(best_math_schools)
# Q2.    Identifying the top 10 performing schools
# Create new column for total_SAT
schools['total_SAT'] = schools['average_math'] + schools['average_reading'] + schools['average_writing']

# Sort the DataFrame by total_SAT in descending order
top_10_schools = schools.sort_values(by='total_SAT', ascending=False)

# Select top 10 schools with relevant columns
top_10_schools = top_10_schools[['school_name', 'total_SAT']].head(10)

# Display the result
print(top_10_schools)
# Q3.    Locating the NYC borough with the largest standard deviation in SAT performance
# Group the data by borough and stats
borough_stats = schools.groupby('borough')['total_SAT'].agg(['count','mean', 'std']).round(2)
borough_stats.columns = ['num_schools', 'average_SAT', 'std_SAT']

# Find the largest Standard Deviation
largest_std_dev = borough_stats.sort_values(by='std_SAT', ascending=False).head(1).reset_index()

# Display the results
print(largest_std_dev)