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...1. Which NYC schools have the best math results?
1.Solution
- Sort first the values in "average_math" in descending order using .sort_values(ascending=False).
sorted_math = schools.sort_values('average_math', ascending=False)
sorted_math.head()- To get the best math results, get first the 80% of 800 (maximum possible score) and the result is 640. Use this to filter the results.
per_80 = 800 * 0.8
atleast_80 = sorted_math[sorted_math['average_math'] >= per_80]
# Get the column ["school_name", "average_math"] of the results, then store it to "best_math_schools"
best_math_schools = atleast_80[["school_name", "average_math"]]
best_math_schools2. What are the top 10 performing schools based on the combined SAT scores?
2. Solution
- Get the sum of
average_math,average_reading,average_writing, then store the result to a variable namedtotal_SAT
schools['total_SAT'] = schools['average_math'] + schools['average_reading'] + schools['average_writing']
schools.head()- Sort the values of
total_SATin descending orders (ascending=False), store them in a new column named"total_SAT"and store the results as a pandas DataFrame calledtop_10_schools