{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "sugar.ipynb", "version": "0.3.2", "provenance": [], "collapsed_sections": [], "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "metadata": { "id": "4ruQxJsnCETI", "colab_type": "text" }, "cell_type": "markdown", "source": [ "# Sugar" ] }, { "metadata": { "id": "d8AGoqX2Ou8R", "colab_type": "text" }, "cell_type": "markdown", "source": [ "## Sugar and Education" ] }, { "metadata": { "id": "aDl4Ar_0K5WA", "colab_type": "text" }, "cell_type": "markdown", "source": [ "### Data Cleaning" ] }, { "metadata": { "id": "XXmY_gfbK9-M", "colab_type": "text" }, "cell_type": "markdown", "source": [ "#### CDC 2013 Source\n", "\n", "TABLE 3. Crude prevalence* of sugar-sweetened beverage† consumption ≥1 time/day among adults, by employment status, education, and state — Behavioral Risk Factor Surveillance System, 23 states and District of Columbia, 2013\n", "\n", "https://www.cdc.gov/mmwr/volumes/65/wr/mm6507a1.htm" ] }, { "metadata": { "id": "eCQv8O8LBrQa", "colab_type": "code", "colab": {} }, "cell_type": "code", "source": [ "import pandas as pd\n" ], "execution_count": 0, "outputs": [] }, { "metadata": { "id": "naakM--4Jnvr", "colab_type": "code", "outputId": "63309b7e-4500-44a0-ba23-1916ee7e1130", "colab": { "base_uri": "https://localhost:8080/", "height": 235 } }, "cell_type": "code", "source": [ "cdc_2013 = pd.read_csv(\"https://raw.githubusercontent.com/noahgift/sugar/master/data/education_sugar_cdc_2003.csv\")\n", "cdc_2013.set_index(\"State\", inplace=True)\n", "cdc_2013.head()" ], "execution_count": 33, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
EmployedNot employedRetired<High schoolHigh schoolSome collegeCollege graduate
State
Alaska26.2 (23.6–28.9)32.1 (27.8–36.8)16.0 (12.6–20.2)47.1 (37.8–56.5)34.9 (31.1–38.9)24.2 (21.0–27.8)12.9 (10.5–15.7)
Arizona33.0 (28.5–37.8)28.7 (23.5–34.5)13.8 (10.8–17.5)40.4 (30.9–50.7)36.5 (30.7–42.7)24.4 (19.9–29.4)14.6 (11.6–18.3)
California22.9 (20.9–25.1)30.2 (27.1–33.4)15.0 (12.2–18.2)38.5 (34.2–43.0)29.9 (26.5–33.7)21.4 (18.8–24.2)11.5 (9.8–13.5)
Connecticut18.9 (17.1–20.9)24.3 (20.8–28.2)15.0 (12.7–17.7)27.8 (22.4–33.9)26.9 (23.7–30.3)19.9 (17.2–23.0)10.2 (8.7–12.0)
District of Columbia18.5 (15.7–21.7)34.6 (29.5–40.1)18.5 (15.3–22.1)45.6 (36.4–55.2)39.0 (33.1–45.2)28.9 (23.4–35.0)8.4 (7.0–10.1)
\n", "
" ], "text/plain": [ " Employed Not employed Retired \\\n", "State \n", "Alaska 26.2 (23.6–28.9) 32.1 (27.8–36.8) 16.0 (12.6–20.2) \n", "Arizona 33.0 (28.5–37.8) 28.7 (23.5–34.5) 13.8 (10.8–17.5) \n", "California 22.9 (20.9–25.1) 30.2 (27.1–33.4) 15.0 (12.2–18.2) \n", "Connecticut 18.9 (17.1–20.9) 24.3 (20.8–28.2) 15.0 (12.7–17.7) \n", "District of Columbia 18.5 (15.7–21.7) 34.6 (29.5–40.1) 18.5 (15.3–22.1) \n", "\n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
StateEmployedNot employedRetired<High schoolHigh schoolSome collegeCollege graduate
0Alaska26.232.116.047.134.924.212.9
1Arizona33.028.713.840.436.524.414.6
2California22.930.215.038.529.921.411.5
3Connecticut18.924.315.027.826.919.910.2
4District of Columbia18.534.618.545.639.028.98.4
\n", "" ], "text/plain": [ " State Employed Not employed Retired \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
EmployedNot employedRetired<High schoolHigh schoolSome collegeCollege graduate
count24.00000024.00000024.00000024.00000024.00000024.00000024.000000
mean32.32500035.40833318.53333344.66250037.41666730.26250017.358333
std9.9178039.0564855.9751428.5886588.2433998.4901386.730264
min16.70000021.5000008.90000027.80000021.50000016.9000007.800000
25%23.40000029.75000014.62500039.62500031.92500024.20000012.850000
50%31.55000032.60000016.75000046.35000036.75000028.20000015.300000
75%42.02500046.02500022.55000051.20000046.52500039.25000023.500000
max49.70000049.50000029.70000060.00000050.80000047.20000034.900000
\n", "" ], "text/plain": [ " Employed Not employed Retired ] 85.63K --.-KB/s in 0.02s \n", "\n", "2019-03-20 23:57:50 (3.39 MB/s) - ‘us-states.json.2’ saved [87688/87688]\n", "\n", "total 280\n", "drwxr-xr-x 1 root root 4096 Mar 8 17:26 sample_data\n", "-rw-r--r-- 1 root root 87688 Mar 20 22:43 us-states.json\n", "-rw-r--r-- 1 root root 87688 Mar 20 22:43 us-states.json.1\n", "-rw-r--r-- 1 root root 87688 Mar 20 23:57 us-states.json.2\n" ], "name": "stdout" } ] }, { "metadata": { "id": "g1iyLlkxbnkM", "colab_type": "text" }, "cell_type": "markdown", "source": [ "#### Low Education == High Sugar" ] }, { "metadata": { "id": "of0h-vnsQtMU", "colab_type": "code", "outputId": "5e73542e-8ce5-4805-835f-5ee97a221300", "colab": { "base_uri": "https://localhost:8080/", "height": 925 } }, "cell_type": "code", "source": [ "import folium\n", "m = folium.Map(location=[36, -102], zoom_start=3)\n", "\n", "folium.Choropleth(\n", " geo_data=\"us-states.json\",\n", " name='choropleth',\n", " data=cdc_2013,\n", " columns=['State', '
" ], "text/plain": [ "" ] }, "metadata": { "tags": [] }, "execution_count": 38 } ] }, { "metadata": { "id": "3zDYaAMccR5q", "colab_type": "text" }, "cell_type": "markdown", "source": [ "#### College Education Major Decrease in Sugar Intake" ] }, { "metadata": { "id": "8S7rcdmKcWq8", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 925 }, "outputId": "f2c5647d-8b71-4858-94eb-374cfef4fba0" }, "cell_type": "code", "source": [ "import folium\n", "m = folium.Map(location=[36, -102], zoom_start=3)\n", "\n", "folium.Choropleth(\n", " geo_data=\"us-states.json\",\n", " name='choropleth',\n", " data=cdc_2003,\n", " columns=['State', 'College graduate'],\n", " key_on='feature.properties.name',\n", " fill_color='OrRd',\n", " fill_opacity=0.7,\n", " line_opacity=0.2,\n", " legend_name='College graduate and Grams Sugar Intake Daily'\n", ").add_to(m)\n", "\n", "folium.LayerControl().add_to(m)\n", "\n", "m" ], "execution_count": 39, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": { "tags": [] }, "execution_count": 39 } ] }, { "metadata": { "id": "Ano4m3I_csL9", "colab_type": "text" }, "cell_type": "markdown", "source": [ "### Median Daily Sugar Intake by Category" ] }, { "metadata": { "id": "YOpxJ23RgxtV", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 68 }, "outputId": "e80630f4-91d8-44e8-ce49-ae78cbdc7d02" }, "cell_type": "code", "source": [ "cdc_2003.columns" ], "execution_count": 14, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "Index(['State', 'Employed', 'Not employed', 'Retired', '" ] }, "metadata": { "tags": [] } } ] }, { "metadata": { "id": "eowEt1oejYFB", "colab_type": "code", "colab": {} }, "cell_type": "code", "source": [ "" ], "execution_count": 0, "outputs": [] } ] }