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()

# Start coding here...
# Add as many cells as you like...

Step 1: Finding Schools with the Best Math Scores

Filter the data to find schools where the average_math score is at least 80% of the maximum possible score (800). Sort and save the results in a DataFrame.

# Define the threshold for the best math scores
threshold = 0.8 * 800  # 80% of the maximum score (800)

# Filter the data for schools meeting the threshold for average_math
best_math_schools = schools[schools['average_math'] >= threshold][['school_name', 'average_math']]

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

# Display the resulting DataFrame for schools with the best math scores
from IPython.display import display
print("Best Math Schools:")
display(best_math_schools)

Step 2: Identifying the Top 10 Performing Schools

Compute a new column, total_SAT, which is the sum of the scores for math, reading, and writing. Then sort and select the top 10 schools.

# Add a new column for the total SAT score
schools['total_SAT'] = schools['average_math'] + schools['average_reading'] + schools['average_writing']

# Sort the data by total_SAT in descending order and select the top 10 schools
top_10_schools = schools[['school_name', 'total_SAT']].sort_values(by='total_SAT', ascending=False).head(10)

# Display the resulting DataFrame for the top 10 performing schools
print("Top 10 Performing Schools:")
display(top_10_schools)

Step 3: Locating the NYC Borough with the Largest Standard Deviation

Goup the data by borough to compute the count of schools, mean, and standard deviation of total_SAT. Then find the borough with the largest standard deviation.

# Group the data by borough and calculate required statistics
borough_stats = schools.groupby('borough')['total_SAT'].agg(['count', 'mean', 'std']).reset_index()

# Round the numerical columns to two decimal places
borough_stats = borough_stats.round({'mean': 2, 'std': 2})

# Find the borough with the largest standard deviation
largest_std_dev = borough_stats[borough_stats['std'] == borough_stats['std'].max()]

# Rename the columns for clarity
largest_std_dev = largest_std_dev.rename(columns={
    'borough': 'borough',
    'count': 'num_schools',
    'mean': 'average_SAT',
    'std': 'std_SAT'
})

# Display the resulting DataFrame for the borough with the largest standard deviation
print("Borough with Largest SAT Std Dev")
display(largest_std_dev)