## EXPLORING NYC PUBLIC SCHOOL TEST RESULT SCORES

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.

We have been provided with a dataset called schools.csv, and tasked with answering three key questions about New York City (NYC) public school SAT performance:

- Which NYC schools have the best math results?
- What are the top 10 performing schools based on the combined SAT scores?
- Which single borough has the largest standard deviation in the combined SAT score?

### Reading and previewing data

```
# Import libraries
import pandas as pd
# Read in the data
schools = pd.read_csv("schools.csv")
# Preview the data
schools.head()
```

### Data Analysis

#### 1. Which NYC schools have the best math results?

Ten schools achieved at least 80% of the maximum math score, with `Stuyvesant High School`

leading with an average math score of 754.

```
# Filter schools with math scores at least 80% of the maximum (800)
best_math_schools = schools.loc[schools['average_math'] / 800 >= 0.8, ['school_name', 'average_math']]
# Sort schools by average math score descending
best_math_schools.sort_values(by='average_math', ascending=False, inplace=True)
# Display filtered and sorted dataframe
best_math_schools
```

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

Stuyvesant High School emerged as the school with the highest combined SAT scores of math, reading, and writing, totaling 2144. Bronx High School of Science and Staten Island Technical High School tied for second place with 2041.

```
# Calculate total SAT scores by summing math, reading, and writing scores
schools['total_SAT'] = schools[['average_math', 'average_reading', 'average_writing']].sum(axis=1)
# Sort schools by total SAT score in descending order
top_10_schools = schools[['school_name', 'total_SAT']].sort_values(by='total_SAT', ascending=False)
# Select the top 10 schools with the highest total SAT scores
top_10_schools = top_10_schools.nlargest(10, 'total_SAT')
# Display the top 10 schools
top_10_schools
```

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

Manhattan had the largest standard deviation of combined SAT scores, at 230.29. It also had a total of 89 schools with a combined average of `total_SAT`

scores of 1340.13.

```
# Group schools by borough
grouped = schools.groupby('borough')
# Calculate the standard deviation of total SAT scores for each borough
borough_std_dev = grouped['total_SAT'].std()
# Sort boroughs by standard deviation of total SAT scores in descending order
std_dev_ordered = borough_std_dev.sort_values(ascending=False)
# Display boroughs ordered by standard deviation
display(std_dev_ordered)
# Select the borough with the largest standard deviation
largest_std = std_dev_ordered.nlargest(1)
```

```
# Count schools grouped by borough and subset for schools in Manhattan
number_of_schools = grouped['school_name'].count()['Manhattan']
# Calculate the average SAT score in Manhattan rounded to 2 decimal places
average_SAT = grouped['total_SAT'].mean()['Manhattan'].round(2)
# Create list with borough, schools count, average SAT, and SAT standard deviation
largest_std_dev_list = [{'borough': largest_std.index[0],
'num_schools': number_of_schools,
'average_SAT': average_SAT,
'std_SAT': largest_std.values[0].round(2)}]
# Convert largest_std_dev_list to dataframe with one row
largest_std_dev = pd.DataFrame(largest_std_dev_list)
# Display DataFrame
largest_std_dev
```