{ "cells": [ { "cell_type": "code", "execution_count": 22, "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 secret import get_key" ] }, { "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": 23, "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": 24, "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", "]\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", "\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)" ] } ], "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 }