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()
# Start coding here...
# Add as many cells as you like...# Create filtered dataframe
best_math_schools = pd.DataFrame(schools[schools["average_math"]>=(0.80*800)].sort_values("average_math", ascending=False))
# Filter to select only interested columns
best_math_schools = best_math_schools[["school_name", "average_math"]]
best_math_schools.head()# Add new "total_SAT" column
schools["total_SAT"] = schools["average_math"] + schools["average_reading"] + schools["average_writing"]
# Sort by "total_SAT" from highest to lowest
schools_sorted = schools.sort_values("total_SAT", ascending=False)
# Limit to the top 10
schools_sorted_10 = schools_sorted[:10]
# Create new dataframe with only the interested columns
top_10_schools=pd.DataFrame(schools_sorted_10[["school_name", "total_SAT"]])
print(top_10_schools.head())# Group by borough and compute std per group
std_per_borough = schools.groupby("borough")["total_SAT"].agg(["count", "mean", "std"]).round(2)
# Find the borough with max std
borough_max_std = std_per_borough.max()
largest_std_dev = std_per_borough[std_per_borough["std"]==std_per_borough["std"].max()]
# Rename columns
largest_std_dev = largest_std_dev.rename(columns={"count":"num_schools", "mean":"average_SAT", "std":"std_SAT"})
# Create dataframe
largest_std_dev = pd.DataFrame(largest_std_dev)
print(largest_std_dev)