Archived
1
0
This repository has been archived on 2025-04-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
schools/main/analysis.ipynb
2022-04-30 13:45:38 -04:00

827 lines
41 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"cells": [
{
"cell_type": "code",
"execution_count": 235,
"metadata": {},
"outputs": [],
"source": [
"# imports\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"from great_schools import get_nearby_schools\n",
"from distance import get_distance\n",
"from secret import get_key\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Shaun and Daniela's Boston Public School Analysis\n",
"#### 2021.04.10"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Fetch the API key from the local filesystem."
]
},
{
"cell_type": "code",
"execution_count": 236,
"metadata": {},
"outputs": [],
"source": [
"# get the API key\n",
"api_key_file = '../keys/api.key'\n",
"api_key = get_key(api_key_file)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the `nearby_schools` API endpoint to grab raw data of all schools within the maximum radius"
]
},
{
"cell_type": "code",
"execution_count": 237,
"metadata": {},
"outputs": [],
"source": [
"# Some columns will dropped immediately as pre-processing.\n",
"drops = [\n",
" 'nces-id',\n",
" 'school-summary',\n",
" 'street',\n",
" 'fipscounty',\n",
" 'phone',\n",
" 'fax',\n",
" 'web-site',\n",
" 'overview-url',\n",
" 'rating-description',\n",
" 'distance',\n",
"]\n",
"\n",
"# Grab data for Boston.\n",
"refresh = False\n",
"boston_nearby_schools_file = '../data/nearby_schools/boston.csv'\n",
"if refresh:\n",
" boston_schools = get_nearby_schools(api_key,\"42.3\",\"-71.2\",\"50\")\n",
" boston_df = pd.DataFrame.from_dict(boston_schools)\n",
" boston_df.drop(columns=drops,inplace=True)\n",
" boston_df.to_csv(boston_nearby_schools_file, )\n",
"else:\n",
" boston_df = pd.read_csv(boston_nearby_schools_file)\n",
" boston_df.set_index(keys=[\"universal-id\"], drop=True, inplace=True)\n",
" boston_df.drop(columns=[\"Unnamed: 0\"], inplace=True)\n",
"\n",
"# Grab data for Buffalo.\n",
"refresh = False\n",
"buffalo_nearby_schools_file = '../data/nearby_schools/buffalo.csv'\n",
"if refresh:\n",
" buffalo_schools = get_nearby_schools(api_key,\"42.9625\",\"-78.7425\",\"50\")\n",
" buffalo_df = pd.DataFrame.from_dict(buffalo_schools)\n",
" buffalo_df.drop(columns=drops,inplace=True)\n",
" buffalo_df.to_csv(buffalo_nearby_schools_file)\n",
"else:\n",
" buffalo_df = pd.read_csv(buffalo_nearby_schools_file)\n",
" buffalo_df.set_index(keys=[\"universal-id\"], drop=True, inplace=True)\n",
" buffalo_df.drop(columns=[\"Unnamed: 0\"], inplace=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Process the `lat` and `lon` columns from the API output into tuples.\n",
"\n",
"Then create two new columns:\n",
"- Distance to Downtown\n",
"- Distance to Work"
]
},
{
"cell_type": "code",
"execution_count": 238,
"metadata": {},
"outputs": [],
"source": [
"# Form tuple to represent coordinates\n",
"boston_df['coordinates'] = list(zip(boston_df.lat,boston_df.lon))\n",
"#boston_df.drop(columns=['lat', 'lon'], inplace=True)\n",
"\n",
"# Define coordinates of important places\n",
"downtown=(42.3674836866797, -71.07134540735377) # Science Museum\n",
"work=(42.47381059540949, -71.25414135292398) # Hartwell\n",
"\n",
"# Create new columns to tabulate distance to these important places\n",
"boston_df['distance-to-downtown'] = boston_df['coordinates'].apply(func=get_distance,p2=downtown)\n",
"boston_df['distance-to-work'] = boston_df['coordinates'].apply(func=get_distance,p2=work)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We should definitely removal all schools that aren't in Massachusetts."
]
},
{
"cell_type": "code",
"execution_count": 239,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"There are 1789 schools from the original API results.\n",
"Allowing only schools from Massachusetts reduces the dataset to 1375 schools.\n"
]
}
],
"source": [
"print(f'There are {len(boston_df)} schools from the original API results.')\n",
"\n",
"# only allow from MA\n",
"boston_df = boston_df[boston_df['state'] == \"MA\"]\n",
"print(f'Allowing only schools from Massachusetts reduces the dataset to {len(boston_df)} schools.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"How many unique district id's are there?"
]
},
{
"cell_type": "code",
"execution_count": 240,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"There are 230 unique school districts.\n",
"\n"
]
}
],
"source": [
"# get unique districts\n",
"districts = boston_df[\"district-id\"].unique()\n",
"print(f'\\nThere are {len(districts)} unique school districts.\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Which of these districts are close to both work and downtown boston?"
]
},
{
"cell_type": "code",
"execution_count": 241,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"There are 90 school districts within reasonable proximity to downtown and work.\n",
"\n",
"There are 699 schools within these proximal districts.\n",
"\n"
]
}
],
"source": [
"# calculate distance to PoI using geo-center of districts\n",
"distances_to_downtown = {k: np.mean(list(v)) for k, v in boston_df.groupby('district-id')['distance-to-downtown']}\n",
"distances_to_work = {k: np.mean(list(v)) for k, v in boston_df.groupby('district-id')['distance-to-work']}\n",
"\n",
"df_downtown = pd.DataFrame.from_dict(distances_to_downtown, orient='index')\n",
"df_work = pd.DataFrame.from_dict(distances_to_work, orient='index')\n",
"\n",
"# merge these new columns\n",
"both_df = pd.merge(left=df_downtown, right=df_work, how='inner', left_index=True, right_index=True)\n",
"both_df.rename(columns={'0_x': \"downtown\", '0_y': \"work\"}, inplace=True)\n",
"\n",
"both_df = both_df[both_df[\"downtown\"] < 35.0]\n",
"both_df = both_df[both_df[\"work\"] < 20.0]\n",
"\n",
"print(f'\\nThere are {len(both_df)} school districts within reasonable proximity to downtown and work.\\n')\n",
"\n",
"# filter out all schools which aren't in proximal districts\n",
"proximal_district_ids = list(both_df.index)\n",
"boston_df = boston_df[boston_df['district-id'].isin(proximal_district_ids)]\n",
"\n",
"print(f'There are {len(boston_df)} schools within these proximal districts.\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's drop any districts that have an average rating below the school population mean."
]
},
{
"cell_type": "code",
"execution_count": 242,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Of the remaining 699 schools, the average rating is 5.664546899841017.\n",
"\n",
"There are 56 districts remaining after pruning districts whose collective average is below the population mean rating.\n",
"\n",
"Which are, ['Acton-Boxborough School District', 'Andover School District', 'Arlington Public Schools', 'Ashland School District', 'Assabet Valley Regional Vocational Technical School District', 'Bedford School District', 'Belmont School District', 'Billerica School District', 'Boxford School District', 'Brookline School District', 'Burlington School District', 'Cambridge School District', 'Carlisle School District', 'Chelmsford School District', 'Concord School District', 'Concord-Carlisle School District', 'Dover School District', 'Dover-Sherborn School District', 'Dracut School District', 'Essex North Shore Agricultural and Technical School District', 'Groton-Dunstable School District', 'Harvard School District', 'Lexington School District', 'Lincoln-Sudbury School District', 'Littleton School District', 'Lynnfield School District', 'Marblehead School District', 'Masconomet School District', 'Melrose School District', 'Middleton School District', 'Milton School District', 'Nahant School District', 'Nashoba School District', 'Natick School District', 'Needham School District', 'Newton School District', 'North Andover School District', 'North Reading School District', 'Norwood School District', 'Quincy School District', 'Reading School District', 'Shawsheen Valley Regional Vocational Technical School District', 'Sherborn School District', 'Southborough School District', 'Stoneham School District', 'Sudbury School District', 'Topsfield School District', 'Tyngsborough School District', 'Wakefield School District', 'Wayland School District', 'Wellesley School District', 'Westford School District', 'Weston School District', 'Westwood School District', 'Wilmington School District', 'Winchester School District']\n"
]
}
],
"source": [
"# get the mean rating from the entire population of schools\n",
"mean_rating = boston_df['rating'].mean()\n",
"std_rating = boston_df['rating'].std()\n",
"\n",
"print(f'\\nOf the remaining {len(boston_df)} schools, the average rating is {mean_rating}.')\n",
"\n",
"# compute the average rating for each district\n",
"ave_ratings = {k: np.mean(v) for k, v in boston_df.groupby(by='district-id')['rating']}\n",
"\n",
"# keep only districts that are above the population mean\n",
"not_low_performing = [k for k, v in ave_ratings.items() if v > mean_rating]\n",
"boston_df = boston_df[boston_df['district-id'].isin(not_low_performing)]\n",
"\n",
"districts = sorted(list(boston_df['district-name'].unique()))\n",
"print(f'\\nThere are {len(districts)} districts remaining after pruning districts whose collective average is below the population mean rating.\\n')\n",
"print(f'Which are, {districts}')"
]
},
{
"cell_type": "code",
"execution_count": 243,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>state-id</th>\n",
" <th>type</th>\n",
" <th>level-codes</th>\n",
" <th>level</th>\n",
" <th>city</th>\n",
" <th>state</th>\n",
" <th>zip</th>\n",
" <th>county</th>\n",
" <th>lat</th>\n",
" <th>lon</th>\n",
" <th>district-id</th>\n",
" <th>rating</th>\n",
" <th>year</th>\n",
" <th>coordinates</th>\n",
" <th>distance-to-downtown</th>\n",
" <th>distance-to-work</th>\n",
" </tr>\n",
" <tr>\n",
" <th>district-name</th>\n",
" <th>name</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">Newton School District</th>\n",
" <th>Charles E Brown Middle School</th>\n",
" <td>2070310</td>\n",
" <td>public</td>\n",
" <td>m</td>\n",
" <td>6,7,8</td>\n",
" <td>Newton Centre</td>\n",
" <td>MA</td>\n",
" <td>2459</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.308750</td>\n",
" <td>-71.190292</td>\n",
" <td>304</td>\n",
" <td>9.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.30875, -71.190292)</td>\n",
" <td>7.300583</td>\n",
" <td>11.852619</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Oak Hill Middle School</th>\n",
" <td>2070320</td>\n",
" <td>public</td>\n",
" <td>m</td>\n",
" <td>6,7,8</td>\n",
" <td>Newton</td>\n",
" <td>MA</td>\n",
" <td>2459</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.310009</td>\n",
" <td>-71.191544</td>\n",
" <td>304</td>\n",
" <td>8.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.310009, -71.191544)</td>\n",
" <td>7.306174</td>\n",
" <td>11.751548</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Countryside Elementary School</th>\n",
" <td>2070040</td>\n",
" <td>public</td>\n",
" <td>e</td>\n",
" <td>KG,1,2,3,4,5</td>\n",
" <td>Newton Highlands</td>\n",
" <td>MA</td>\n",
" <td>2461</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.313141</td>\n",
" <td>-71.202377</td>\n",
" <td>304</td>\n",
" <td>7.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.313141, -71.202377)</td>\n",
" <td>7.667944</td>\n",
" <td>11.403174</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Memorial Spaulding Elementary School</th>\n",
" <td>2070105</td>\n",
" <td>public</td>\n",
" <td>e</td>\n",
" <td>KG,1,2,3,4,5</td>\n",
" <td>Newton Centre</td>\n",
" <td>MA</td>\n",
" <td>2459</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.302044</td>\n",
" <td>-71.177696</td>\n",
" <td>304</td>\n",
" <td>8.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.302044, -71.177696)</td>\n",
" <td>7.062535</td>\n",
" <td>12.483971</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Newton South High School</th>\n",
" <td>2070510</td>\n",
" <td>public</td>\n",
" <td>h</td>\n",
" <td>9,10,11,12</td>\n",
" <td>Newton Centre</td>\n",
" <td>MA</td>\n",
" <td>2459</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.314308</td>\n",
" <td>-71.186493</td>\n",
" <td>304</td>\n",
" <td>7.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.314308, -71.186493)</td>\n",
" <td>6.929197</td>\n",
" <td>11.540487</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Groton-Dunstable School District</th>\n",
" <th>Florence Roche School</th>\n",
" <td>6730010</td>\n",
" <td>public</td>\n",
" <td>e</td>\n",
" <td>KG,1,2,3,4</td>\n",
" <td>Groton</td>\n",
" <td>MA</td>\n",
" <td>1450</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.616894</td>\n",
" <td>-71.577682</td>\n",
" <td>198</td>\n",
" <td>7.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.616894, -71.577682)</td>\n",
" <td>31.001218</td>\n",
" <td>19.195452</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"2\" valign=\"top\">Tyngsborough School District</th>\n",
" <th>Tyngsborough Middle School</th>\n",
" <td>3010305</td>\n",
" <td>public</td>\n",
" <td>m</td>\n",
" <td>6,7,8</td>\n",
" <td>Tyngsborough</td>\n",
" <td>MA</td>\n",
" <td>1879</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.696640</td>\n",
" <td>-71.406586</td>\n",
" <td>418</td>\n",
" <td>6.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.69664, -71.406586)</td>\n",
" <td>28.415381</td>\n",
" <td>17.226867</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tyngsborough High School</th>\n",
" <td>3010505</td>\n",
" <td>public</td>\n",
" <td>h</td>\n",
" <td>9,10,11,12</td>\n",
" <td>Tyngsborough</td>\n",
" <td>MA</td>\n",
" <td>1879</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.697529</td>\n",
" <td>-71.408226</td>\n",
" <td>418</td>\n",
" <td>8.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.697529, -71.408226)</td>\n",
" <td>28.514503</td>\n",
" <td>17.319230</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"2\" valign=\"top\">Groton-Dunstable School District</th>\n",
" <th>Swallow/Union School</th>\n",
" <td>6730005</td>\n",
" <td>public</td>\n",
" <td>e</td>\n",
" <td>KG,1,2,3,4</td>\n",
" <td>Dunstable</td>\n",
" <td>MA</td>\n",
" <td>1827</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.673241</td>\n",
" <td>-71.482529</td>\n",
" <td>198</td>\n",
" <td>9.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.673241, -71.482529)</td>\n",
" <td>29.723989</td>\n",
" <td>18.012628</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Groton-Dunstable Regional High School</th>\n",
" <td>6730505</td>\n",
" <td>public</td>\n",
" <td>h</td>\n",
" <td>9,10,11,12,UG</td>\n",
" <td>Groton</td>\n",
" <td>MA</td>\n",
" <td>1450</td>\n",
" <td>Middlesex County</td>\n",
" <td>42.651093</td>\n",
" <td>-71.540405</td>\n",
" <td>198</td>\n",
" <td>10.0</td>\n",
" <td>2021.0</td>\n",
" <td>(42.651093, -71.540405)</td>\n",
" <td>30.877490</td>\n",
" <td>19.019974</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>325 rows × 16 columns</p>\n",
"</div>"
],
"text/plain": [
" state-id \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 2070310 \n",
" Oak Hill Middle School 2070320 \n",
" Countryside Elementary School 2070040 \n",
" Memorial Spaulding Elementary School 2070105 \n",
" Newton South High School 2070510 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School 6730010 \n",
"Tyngsborough School District Tyngsborough Middle School 3010305 \n",
" Tyngsborough High School 3010505 \n",
"Groton-Dunstable School District Swallow/Union School 6730005 \n",
" Groton-Dunstable Regional High School 6730505 \n",
"\n",
" type \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School public \n",
" Oak Hill Middle School public \n",
" Countryside Elementary School public \n",
" Memorial Spaulding Elementary School public \n",
" Newton South High School public \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School public \n",
"Tyngsborough School District Tyngsborough Middle School public \n",
" Tyngsborough High School public \n",
"Groton-Dunstable School District Swallow/Union School public \n",
" Groton-Dunstable Regional High School public \n",
"\n",
" level-codes \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School m \n",
" Oak Hill Middle School m \n",
" Countryside Elementary School e \n",
" Memorial Spaulding Elementary School e \n",
" Newton South High School h \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School e \n",
"Tyngsborough School District Tyngsborough Middle School m \n",
" Tyngsborough High School h \n",
"Groton-Dunstable School District Swallow/Union School e \n",
" Groton-Dunstable Regional High School h \n",
"\n",
" level \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 6,7,8 \n",
" Oak Hill Middle School 6,7,8 \n",
" Countryside Elementary School KG,1,2,3,4,5 \n",
" Memorial Spaulding Elementary School KG,1,2,3,4,5 \n",
" Newton South High School 9,10,11,12 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School KG,1,2,3,4 \n",
"Tyngsborough School District Tyngsborough Middle School 6,7,8 \n",
" Tyngsborough High School 9,10,11,12 \n",
"Groton-Dunstable School District Swallow/Union School KG,1,2,3,4 \n",
" Groton-Dunstable Regional High School 9,10,11,12,UG \n",
"\n",
" city \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School Newton Centre \n",
" Oak Hill Middle School Newton \n",
" Countryside Elementary School Newton Highlands \n",
" Memorial Spaulding Elementary School Newton Centre \n",
" Newton South High School Newton Centre \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School Groton \n",
"Tyngsborough School District Tyngsborough Middle School Tyngsborough \n",
" Tyngsborough High School Tyngsborough \n",
"Groton-Dunstable School District Swallow/Union School Dunstable \n",
" Groton-Dunstable Regional High School Groton \n",
"\n",
" state \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School MA \n",
" Oak Hill Middle School MA \n",
" Countryside Elementary School MA \n",
" Memorial Spaulding Elementary School MA \n",
" Newton South High School MA \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School MA \n",
"Tyngsborough School District Tyngsborough Middle School MA \n",
" Tyngsborough High School MA \n",
"Groton-Dunstable School District Swallow/Union School MA \n",
" Groton-Dunstable Regional High School MA \n",
"\n",
" zip \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 2459 \n",
" Oak Hill Middle School 2459 \n",
" Countryside Elementary School 2461 \n",
" Memorial Spaulding Elementary School 2459 \n",
" Newton South High School 2459 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School 1450 \n",
"Tyngsborough School District Tyngsborough Middle School 1879 \n",
" Tyngsborough High School 1879 \n",
"Groton-Dunstable School District Swallow/Union School 1827 \n",
" Groton-Dunstable Regional High School 1450 \n",
"\n",
" county \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School Middlesex County \n",
" Oak Hill Middle School Middlesex County \n",
" Countryside Elementary School Middlesex County \n",
" Memorial Spaulding Elementary School Middlesex County \n",
" Newton South High School Middlesex County \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School Middlesex County \n",
"Tyngsborough School District Tyngsborough Middle School Middlesex County \n",
" Tyngsborough High School Middlesex County \n",
"Groton-Dunstable School District Swallow/Union School Middlesex County \n",
" Groton-Dunstable Regional High School Middlesex County \n",
"\n",
" lat \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 42.308750 \n",
" Oak Hill Middle School 42.310009 \n",
" Countryside Elementary School 42.313141 \n",
" Memorial Spaulding Elementary School 42.302044 \n",
" Newton South High School 42.314308 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School 42.616894 \n",
"Tyngsborough School District Tyngsborough Middle School 42.696640 \n",
" Tyngsborough High School 42.697529 \n",
"Groton-Dunstable School District Swallow/Union School 42.673241 \n",
" Groton-Dunstable Regional High School 42.651093 \n",
"\n",
" lon \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School -71.190292 \n",
" Oak Hill Middle School -71.191544 \n",
" Countryside Elementary School -71.202377 \n",
" Memorial Spaulding Elementary School -71.177696 \n",
" Newton South High School -71.186493 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School -71.577682 \n",
"Tyngsborough School District Tyngsborough Middle School -71.406586 \n",
" Tyngsborough High School -71.408226 \n",
"Groton-Dunstable School District Swallow/Union School -71.482529 \n",
" Groton-Dunstable Regional High School -71.540405 \n",
"\n",
" district-id \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 304 \n",
" Oak Hill Middle School 304 \n",
" Countryside Elementary School 304 \n",
" Memorial Spaulding Elementary School 304 \n",
" Newton South High School 304 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School 198 \n",
"Tyngsborough School District Tyngsborough Middle School 418 \n",
" Tyngsborough High School 418 \n",
"Groton-Dunstable School District Swallow/Union School 198 \n",
" Groton-Dunstable Regional High School 198 \n",
"\n",
" rating \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 9.0 \n",
" Oak Hill Middle School 8.0 \n",
" Countryside Elementary School 7.0 \n",
" Memorial Spaulding Elementary School 8.0 \n",
" Newton South High School 7.0 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School 7.0 \n",
"Tyngsborough School District Tyngsborough Middle School 6.0 \n",
" Tyngsborough High School 8.0 \n",
"Groton-Dunstable School District Swallow/Union School 9.0 \n",
" Groton-Dunstable Regional High School 10.0 \n",
"\n",
" year \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 2021.0 \n",
" Oak Hill Middle School 2021.0 \n",
" Countryside Elementary School 2021.0 \n",
" Memorial Spaulding Elementary School 2021.0 \n",
" Newton South High School 2021.0 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School 2021.0 \n",
"Tyngsborough School District Tyngsborough Middle School 2021.0 \n",
" Tyngsborough High School 2021.0 \n",
"Groton-Dunstable School District Swallow/Union School 2021.0 \n",
" Groton-Dunstable Regional High School 2021.0 \n",
"\n",
" coordinates \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School (42.30875, -71.190292) \n",
" Oak Hill Middle School (42.310009, -71.191544) \n",
" Countryside Elementary School (42.313141, -71.202377) \n",
" Memorial Spaulding Elementary School (42.302044, -71.177696) \n",
" Newton South High School (42.314308, -71.186493) \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School (42.616894, -71.577682) \n",
"Tyngsborough School District Tyngsborough Middle School (42.69664, -71.406586) \n",
" Tyngsborough High School (42.697529, -71.408226) \n",
"Groton-Dunstable School District Swallow/Union School (42.673241, -71.482529) \n",
" Groton-Dunstable Regional High School (42.651093, -71.540405) \n",
"\n",
" distance-to-downtown \\\n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 7.300583 \n",
" Oak Hill Middle School 7.306174 \n",
" Countryside Elementary School 7.667944 \n",
" Memorial Spaulding Elementary School 7.062535 \n",
" Newton South High School 6.929197 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School 31.001218 \n",
"Tyngsborough School District Tyngsborough Middle School 28.415381 \n",
" Tyngsborough High School 28.514503 \n",
"Groton-Dunstable School District Swallow/Union School 29.723989 \n",
" Groton-Dunstable Regional High School 30.877490 \n",
"\n",
" distance-to-work \n",
"district-name name \n",
"Newton School District Charles E Brown Middle School 11.852619 \n",
" Oak Hill Middle School 11.751548 \n",
" Countryside Elementary School 11.403174 \n",
" Memorial Spaulding Elementary School 12.483971 \n",
" Newton South High School 11.540487 \n",
"... ... \n",
"Groton-Dunstable School District Florence Roche School 19.195452 \n",
"Tyngsborough School District Tyngsborough Middle School 17.226867 \n",
" Tyngsborough High School 17.319230 \n",
"Groton-Dunstable School District Swallow/Union School 18.012628 \n",
" Groton-Dunstable Regional High School 19.019974 \n",
"\n",
"[325 rows x 16 columns]"
]
},
"execution_count": 243,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"boston_df.set_index(['district-name','name'],inplace=True)\n",
"boston_df"
]
}
],
"metadata": {
"interpreter": {
"hash": "4fc861b332db140b7b363b167627eee6a3238262e7c99e0237067fec0875fee7"
},
"kernelspec": {
"display_name": "Python 3.8.10 ('venv': venv)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}