{
"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": [
"
"
]
},
{
"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",
" Employed | \n",
" Not employed | \n",
" Retired | \n",
" <High school | \n",
" High school | \n",
" Some college | \n",
" College graduate | \n",
"
\n",
" \n",
" State | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" Alaska | \n",
" 26.2 (23.6–28.9) | \n",
" 32.1 (27.8–36.8) | \n",
" 16.0 (12.6–20.2) | \n",
" 47.1 (37.8–56.5) | \n",
" 34.9 (31.1–38.9) | \n",
" 24.2 (21.0–27.8) | \n",
" 12.9 (10.5–15.7) | \n",
"
\n",
" \n",
" Arizona | \n",
" 33.0 (28.5–37.8) | \n",
" 28.7 (23.5–34.5) | \n",
" 13.8 (10.8–17.5) | \n",
" 40.4 (30.9–50.7) | \n",
" 36.5 (30.7–42.7) | \n",
" 24.4 (19.9–29.4) | \n",
" 14.6 (11.6–18.3) | \n",
"
\n",
" \n",
" California | \n",
" 22.9 (20.9–25.1) | \n",
" 30.2 (27.1–33.4) | \n",
" 15.0 (12.2–18.2) | \n",
" 38.5 (34.2–43.0) | \n",
" 29.9 (26.5–33.7) | \n",
" 21.4 (18.8–24.2) | \n",
" 11.5 (9.8–13.5) | \n",
"
\n",
" \n",
" Connecticut | \n",
" 18.9 (17.1–20.9) | \n",
" 24.3 (20.8–28.2) | \n",
" 15.0 (12.7–17.7) | \n",
" 27.8 (22.4–33.9) | \n",
" 26.9 (23.7–30.3) | \n",
" 19.9 (17.2–23.0) | \n",
" 10.2 (8.7–12.0) | \n",
"
\n",
" \n",
" District of Columbia | \n",
" 18.5 (15.7–21.7) | \n",
" 34.6 (29.5–40.1) | \n",
" 18.5 (15.3–22.1) | \n",
" 45.6 (36.4–55.2) | \n",
" 39.0 (33.1–45.2) | \n",
" 28.9 (23.4–35.0) | \n",
" 8.4 (7.0–10.1) | \n",
"
\n",
" \n",
"
\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",
" State | \n",
" Employed | \n",
" Not employed | \n",
" Retired | \n",
" <High school | \n",
" High school | \n",
" Some college | \n",
" College graduate | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Alaska | \n",
" 26.2 | \n",
" 32.1 | \n",
" 16.0 | \n",
" 47.1 | \n",
" 34.9 | \n",
" 24.2 | \n",
" 12.9 | \n",
"
\n",
" \n",
" 1 | \n",
" Arizona | \n",
" 33.0 | \n",
" 28.7 | \n",
" 13.8 | \n",
" 40.4 | \n",
" 36.5 | \n",
" 24.4 | \n",
" 14.6 | \n",
"
\n",
" \n",
" 2 | \n",
" California | \n",
" 22.9 | \n",
" 30.2 | \n",
" 15.0 | \n",
" 38.5 | \n",
" 29.9 | \n",
" 21.4 | \n",
" 11.5 | \n",
"
\n",
" \n",
" 3 | \n",
" Connecticut | \n",
" 18.9 | \n",
" 24.3 | \n",
" 15.0 | \n",
" 27.8 | \n",
" 26.9 | \n",
" 19.9 | \n",
" 10.2 | \n",
"
\n",
" \n",
" 4 | \n",
" District of Columbia | \n",
" 18.5 | \n",
" 34.6 | \n",
" 18.5 | \n",
" 45.6 | \n",
" 39.0 | \n",
" 28.9 | \n",
" 8.4 | \n",
"
\n",
" \n",
"
\n",
""
],
"text/plain": [
" State Employed Not employed Retired \n",
"\n",
"\n",
" \n",
" \n",
" | \n",
" Employed | \n",
" Not employed | \n",
" Retired | \n",
" <High school | \n",
" High school | \n",
" Some college | \n",
" College graduate | \n",
"
\n",
" \n",
" \n",
" \n",
" count | \n",
" 24.000000 | \n",
" 24.000000 | \n",
" 24.000000 | \n",
" 24.000000 | \n",
" 24.000000 | \n",
" 24.000000 | \n",
" 24.000000 | \n",
"
\n",
" \n",
" mean | \n",
" 32.325000 | \n",
" 35.408333 | \n",
" 18.533333 | \n",
" 44.662500 | \n",
" 37.416667 | \n",
" 30.262500 | \n",
" 17.358333 | \n",
"
\n",
" \n",
" std | \n",
" 9.917803 | \n",
" 9.056485 | \n",
" 5.975142 | \n",
" 8.588658 | \n",
" 8.243399 | \n",
" 8.490138 | \n",
" 6.730264 | \n",
"
\n",
" \n",
" min | \n",
" 16.700000 | \n",
" 21.500000 | \n",
" 8.900000 | \n",
" 27.800000 | \n",
" 21.500000 | \n",
" 16.900000 | \n",
" 7.800000 | \n",
"
\n",
" \n",
" 25% | \n",
" 23.400000 | \n",
" 29.750000 | \n",
" 14.625000 | \n",
" 39.625000 | \n",
" 31.925000 | \n",
" 24.200000 | \n",
" 12.850000 | \n",
"
\n",
" \n",
" 50% | \n",
" 31.550000 | \n",
" 32.600000 | \n",
" 16.750000 | \n",
" 46.350000 | \n",
" 36.750000 | \n",
" 28.200000 | \n",
" 15.300000 | \n",
"
\n",
" \n",
" 75% | \n",
" 42.025000 | \n",
" 46.025000 | \n",
" 22.550000 | \n",
" 51.200000 | \n",
" 46.525000 | \n",
" 39.250000 | \n",
" 23.500000 | \n",
"
\n",
" \n",
" max | \n",
" 49.700000 | \n",
" 49.500000 | \n",
" 29.700000 | \n",
" 60.000000 | \n",
" 50.800000 | \n",
" 47.200000 | \n",
" 34.900000 | \n",
"
\n",
" \n",
"
\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": []
}
]
}