{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "improved-joining", "metadata": {}, "source": [ "Loading Data\n", "============\n", "This notebook loads the NYC School Demographic data.\n", "Working with this dataset, we look at some basic\n", "[Pandas](https://pandas.pydata.org/) operations.\n", "\n", "We assume that you have a basic understanding of Python and\n", "Jupyter notebooks. This is a good start if you are new to\n", "Pandas and data science in Python.\n", "\n", "In particular:\n", "\n", "- loading data from the `nycschools` into a `DataFrame`\n", "- use `head()`, `tail()`, and `Series` (columns) to understand the data\n", "- access column `Series` by name using index notation\n", "- use `unique()`, `min()`, `max()`, `sum()`, and `mean()` to understand series data\n", "\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "cellular-defense", "metadata": {}, "outputs": [], "source": [ "# import schools from the nycschool package\n", "from nycschools import schools\n", "# load the demographic data into a `DataFrame` called df\n", "df = schools.load_school_demographics()\n" ] }, { "cell_type": "markdown", "id": "satisfied-delaware", "metadata": {}, "source": [ "Displaying data tables\n", "-----------------------\n", "If we display `df` notebook shows us some of the data from \n", "the start of the data set and some from the end.\n", "\n", "If we call `df.head()` we get the start of the data. `df.tail()` shows us the end of the data.\n", "\n", "Comment/uncomment the different options to see how they work." ] }, { "cell_type": "code", "execution_count": 6, "id": "ec687e8b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | dbn | \n", "beds | \n", "district | \n", "geo_district | \n", "boro | \n", "school_name | \n", "short_name | \n", "ay | \n", "year | \n", "total_enrollment | \n", "... | \n", "missing_race_ethnicity_data_pct | \n", "swd_n | \n", "swd_pct | \n", "ell_n | \n", "ell_pct | \n", "poverty_n | \n", "poverty_pct | \n", "eni_pct | \n", "clean_name | \n", "zip | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "01M015 | \n", "310100010015 | \n", "1 | \n", "1 | \n", "Manhattan | \n", "P.S. 015 Roberto Clemente | \n", "PS 15 | \n", "2016 | \n", "2016-17 | \n", "178 | \n", "... | \n", "0.000000 | \n", "51 | \n", "0.287000 | \n", "12 | \n", "0.067 | \n", "152 | \n", "0.854 | \n", "0.882 | \n", "roberto clemente | \n", "10009 | \n", "
1 | \n", "01M015 | \n", "310100010015 | \n", "1 | \n", "1 | \n", "Manhattan | \n", "P.S. 015 Roberto Clemente | \n", "PS 15 | \n", "2017 | \n", "2017-18 | \n", "190 | \n", "... | \n", "0.000000 | \n", "49 | \n", "0.258000 | \n", "8 | \n", "0.042 | \n", "161 | \n", "0.847 | \n", "0.890 | \n", "roberto clemente | \n", "10009 | \n", "
2 | \n", "01M015 | \n", "310100010015 | \n", "1 | \n", "1 | \n", "Manhattan | \n", "P.S. 015 Roberto Clemente | \n", "PS 15 | \n", "2018 | \n", "2018-19 | \n", "174 | \n", "... | \n", "0.000000 | \n", "39 | \n", "0.224000 | \n", "8 | \n", "0.046 | \n", "147 | \n", "0.845 | \n", "0.888 | \n", "roberto clemente | \n", "10009 | \n", "
3 | \n", "01M015 | \n", "310100010015 | \n", "1 | \n", "1 | \n", "Manhattan | \n", "P.S. 015 Roberto Clemente | \n", "PS 15 | \n", "2019 | \n", "2019-20 | \n", "190 | \n", "... | \n", "0.000000 | \n", "46 | \n", "0.242000 | \n", "17 | \n", "0.089 | \n", "155 | \n", "0.816 | \n", "0.867 | \n", "roberto clemente | \n", "10009 | \n", "
4 | \n", "01M015 | \n", "310100010015 | \n", "1 | \n", "1 | \n", "Manhattan | \n", "P.S. 015 Roberto Clemente | \n", "PS 15 | \n", "2020 | \n", "2020-21 | \n", "193 | \n", "... | \n", "0.000000 | \n", "43 | \n", "0.223000 | \n", "21 | \n", "0.109 | \n", "158 | \n", "0.819 | \n", "0.856 | \n", "roberto clemente | \n", "10009 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
9996 | \n", "84X730 | \n", "320800860846 | \n", "84 | \n", "8 | \n", "Bronx | \n", "Bronx Charter School for the Arts | \n", "PS 730 | \n", "2016 | \n", "2016-17 | \n", "320 | \n", "... | \n", "0.000000 | \n", "67 | \n", "0.209375 | \n", "51 | \n", "0.159 | \n", "235 | \n", "0.734 | \n", "0.840 | \n", "bronx charter school for the arts | \n", "10474 | \n", "
9997 | \n", "84X730 | \n", "320800860846 | \n", "84 | \n", "8 | \n", "Bronx | \n", "Bronx Charter School for the Arts | \n", "PS 730 | \n", "2017 | \n", "2017-18 | \n", "314 | \n", "... | \n", "0.000000 | \n", "68 | \n", "0.216561 | \n", "57 | \n", "0.182 | \n", "258 | \n", "0.822 | \n", "0.891 | \n", "bronx charter school for the arts | \n", "10474 | \n", "
9998 | \n", "84X730 | \n", "320800860846 | \n", "84 | \n", "8 | \n", "Bronx | \n", "Bronx Charter School for the Arts | \n", "PS 730 | \n", "2018 | \n", "2018-19 | \n", "430 | \n", "... | \n", "0.000000 | \n", "103 | \n", "0.239535 | \n", "71 | \n", "0.165 | \n", "363 | \n", "0.844 | \n", "0.888 | \n", "bronx charter school for the arts | \n", "10474 | \n", "
9999 | \n", "84X730 | \n", "320800860846 | \n", "84 | \n", "8 | \n", "Bronx | \n", "Bronx Charter School for the Arts | \n", "MS 730 | \n", "2019 | \n", "2019-20 | \n", "523 | \n", "... | \n", "0.000000 | \n", "117 | \n", "0.223709 | \n", "69 | \n", "0.132 | \n", "453 | \n", "0.866 | \n", "0.892 | \n", "bronx charter school for the arts | \n", "10474 | \n", "
10000 | \n", "84X730 | \n", "320800860846 | \n", "84 | \n", "8 | \n", "Bronx | \n", "Bronx Charter School for the Arts | \n", "MS 730 | \n", "2020 | \n", "2020-21 | \n", "626 | \n", "... | \n", "0.001597 | \n", "153 | \n", "0.244409 | \n", "78 | \n", "0.125 | \n", "541 | \n", "0.864 | \n", "0.882 | \n", "bronx charter school for the arts | \n", "10474 | \n", "
10001 rows × 51 columns
\n", "\n", " | dbn | \n", "school_name | \n", "total_enrollment | \n", "poverty_n | \n", "
---|---|---|---|---|
0 | \n", "01M015 | \n", "P.S. 015 Roberto Clemente | \n", "178 | \n", "152 | \n", "
1 | \n", "01M015 | \n", "P.S. 015 Roberto Clemente | \n", "190 | \n", "161 | \n", "
2 | \n", "01M015 | \n", "P.S. 015 Roberto Clemente | \n", "174 | \n", "147 | \n", "
3 | \n", "01M015 | \n", "P.S. 015 Roberto Clemente | \n", "190 | \n", "155 | \n", "
4 | \n", "01M015 | \n", "P.S. 015 Roberto Clemente | \n", "193 | \n", "158 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
9996 | \n", "84X730 | \n", "Bronx Charter School for the Arts | \n", "320 | \n", "235 | \n", "
9997 | \n", "84X730 | \n", "Bronx Charter School for the Arts | \n", "314 | \n", "258 | \n", "
9998 | \n", "84X730 | \n", "Bronx Charter School for the Arts | \n", "430 | \n", "363 | \n", "
9999 | \n", "84X730 | \n", "Bronx Charter School for the Arts | \n", "523 | \n", "453 | \n", "
10000 | \n", "84X730 | \n", "Bronx Charter School for the Arts | \n", "626 | \n", "541 | \n", "
10001 rows × 4 columns
\n", "