Last active
July 7, 2020 22:08
-
-
Save ladyrassilon/f11feccde581de7a0d6693a481d48a5f to your computer and use it in GitHub Desktop.
Rough calculations for data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"import requests\n", | |
"import io\n", | |
"import plotly.express as px" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"data_url = \"https://data.cdc.gov/api/views/vsak-wrfu/rows.csv?accessType=DOWNLOAD\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"req = requests.get(data_url)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"b'Data as of,State,MMWR Week,Week ending Date,Sex,Age Group,Total Deaths,COVID-19 Deaths\\n07/01/2020,Un'" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"req.content[0:100]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"raw_df = pd.read_csv(io.StringIO(req.content.decode('utf-8')))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"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>Data as of</th>\n", | |
" <th>State</th>\n", | |
" <th>MMWR Week</th>\n", | |
" <th>Week ending Date</th>\n", | |
" <th>Sex</th>\n", | |
" <th>Age Group</th>\n", | |
" <th>Total Deaths</th>\n", | |
" <th>COVID-19 Deaths</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>Female</td>\n", | |
" <td>Under 1 year</td>\n", | |
" <td>185</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>Female</td>\n", | |
" <td>1-4 years</td>\n", | |
" <td>28</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>Female</td>\n", | |
" <td>5-14 years</td>\n", | |
" <td>48</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>Female</td>\n", | |
" <td>15-24 years</td>\n", | |
" <td>146</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>Female</td>\n", | |
" <td>25-34 years</td>\n", | |
" <td>328</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\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", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>721</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>45-54 years</td>\n", | |
" <td>761</td>\n", | |
" <td>18</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>722</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>55-64 years</td>\n", | |
" <td>1875</td>\n", | |
" <td>32</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>723</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>65-74 years</td>\n", | |
" <td>3024</td>\n", | |
" <td>45</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>724</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>75-84 years</td>\n", | |
" <td>4190</td>\n", | |
" <td>53</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>725</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>85 years and over</td>\n", | |
" <td>5703</td>\n", | |
" <td>78</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>726 rows × 8 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Data as of State MMWR Week Week ending Date Sex \\\n", | |
"0 07/01/2020 United States 5 02/01/2020 Female \n", | |
"1 07/01/2020 United States 5 02/01/2020 Female \n", | |
"2 07/01/2020 United States 5 02/01/2020 Female \n", | |
"3 07/01/2020 United States 5 02/01/2020 Female \n", | |
"4 07/01/2020 United States 5 02/01/2020 Female \n", | |
".. ... ... ... ... ... \n", | |
"721 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"722 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"723 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"724 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"725 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"\n", | |
" Age Group Total Deaths COVID-19 Deaths \n", | |
"0 Under 1 year 185 0 \n", | |
"1 1-4 years 28 0 \n", | |
"2 5-14 years 48 0 \n", | |
"3 15-24 years 146 0 \n", | |
"4 25-34 years 328 0 \n", | |
".. ... ... ... \n", | |
"721 45-54 years 761 18 \n", | |
"722 55-64 years 1875 32 \n", | |
"723 65-74 years 3024 45 \n", | |
"724 75-84 years 4190 53 \n", | |
"725 85 years and over 5703 78 \n", | |
"\n", | |
"[726 rows x 8 columns]" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"raw_df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"all_sex_df = raw_df[raw_df.Sex == \"All Sex\"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"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>Data as of</th>\n", | |
" <th>State</th>\n", | |
" <th>MMWR Week</th>\n", | |
" <th>Week ending Date</th>\n", | |
" <th>Sex</th>\n", | |
" <th>Age Group</th>\n", | |
" <th>Total Deaths</th>\n", | |
" <th>COVID-19 Deaths</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>484</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>Under 1 year</td>\n", | |
" <td>375</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>485</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>1-4 years</td>\n", | |
" <td>64</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>486</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>5-14 years</td>\n", | |
" <td>110</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>487</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>15-24 years</td>\n", | |
" <td>567</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>488</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>25-34 years</td>\n", | |
" <td>1124</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\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", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>721</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>45-54 years</td>\n", | |
" <td>761</td>\n", | |
" <td>18</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>722</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>55-64 years</td>\n", | |
" <td>1875</td>\n", | |
" <td>32</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>723</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>65-74 years</td>\n", | |
" <td>3024</td>\n", | |
" <td>45</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>724</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>75-84 years</td>\n", | |
" <td>4190</td>\n", | |
" <td>53</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>725</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>85 years and over</td>\n", | |
" <td>5703</td>\n", | |
" <td>78</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>242 rows × 8 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Data as of State MMWR Week Week ending Date Sex \\\n", | |
"484 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
"485 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
"486 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
"487 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
"488 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
".. ... ... ... ... ... \n", | |
"721 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"722 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"723 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"724 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"725 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"\n", | |
" Age Group Total Deaths COVID-19 Deaths \n", | |
"484 Under 1 year 375 0 \n", | |
"485 1-4 years 64 0 \n", | |
"486 5-14 years 110 0 \n", | |
"487 15-24 years 567 0 \n", | |
"488 25-34 years 1124 0 \n", | |
".. ... ... ... \n", | |
"721 45-54 years 761 18 \n", | |
"722 55-64 years 1875 32 \n", | |
"723 65-74 years 3024 45 \n", | |
"724 75-84 years 4190 53 \n", | |
"725 85 years and over 5703 78 \n", | |
"\n", | |
"[242 rows x 8 columns]" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"all_sex_df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"whole_us_df = all_sex_df[all_sex_df.State == \"United States\"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"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>Data as of</th>\n", | |
" <th>State</th>\n", | |
" <th>MMWR Week</th>\n", | |
" <th>Week ending Date</th>\n", | |
" <th>Sex</th>\n", | |
" <th>Age Group</th>\n", | |
" <th>Total Deaths</th>\n", | |
" <th>COVID-19 Deaths</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>484</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>Under 1 year</td>\n", | |
" <td>375</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>485</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>1-4 years</td>\n", | |
" <td>64</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>486</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>5-14 years</td>\n", | |
" <td>110</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>487</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>15-24 years</td>\n", | |
" <td>567</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>488</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>5</td>\n", | |
" <td>02/01/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>25-34 years</td>\n", | |
" <td>1124</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\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", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>721</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>45-54 years</td>\n", | |
" <td>761</td>\n", | |
" <td>18</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>722</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>55-64 years</td>\n", | |
" <td>1875</td>\n", | |
" <td>32</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>723</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>65-74 years</td>\n", | |
" <td>3024</td>\n", | |
" <td>45</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>724</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>75-84 years</td>\n", | |
" <td>4190</td>\n", | |
" <td>53</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>725</th>\n", | |
" <td>07/01/2020</td>\n", | |
" <td>United States</td>\n", | |
" <td>26</td>\n", | |
" <td>06/27/2020</td>\n", | |
" <td>All Sex</td>\n", | |
" <td>85 years and over</td>\n", | |
" <td>5703</td>\n", | |
" <td>78</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>242 rows × 8 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Data as of State MMWR Week Week ending Date Sex \\\n", | |
"484 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
"485 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
"486 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
"487 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
"488 07/01/2020 United States 5 02/01/2020 All Sex \n", | |
".. ... ... ... ... ... \n", | |
"721 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"722 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"723 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"724 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"725 07/01/2020 United States 26 06/27/2020 All Sex \n", | |
"\n", | |
" Age Group Total Deaths COVID-19 Deaths \n", | |
"484 Under 1 year 375 0 \n", | |
"485 1-4 years 64 0 \n", | |
"486 5-14 years 110 0 \n", | |
"487 15-24 years 567 0 \n", | |
"488 25-34 years 1124 0 \n", | |
".. ... ... ... \n", | |
"721 45-54 years 761 18 \n", | |
"722 55-64 years 1875 32 \n", | |
"723 65-74 years 3024 45 \n", | |
"724 75-84 years 4190 53 \n", | |
"725 85 years and over 5703 78 \n", | |
"\n", | |
"[242 rows x 8 columns]" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"whole_us_df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"total_deaths = whole_us_df.groupby('Age Group').agg({'COVID-19 Deaths': 'sum'})" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"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>COVID-19 Deaths</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Age Group</th>\n", | |
" <th></th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1-4 years</th>\n", | |
" <td>6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15-24 years</th>\n", | |
" <td>142</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>25-34 years</th>\n", | |
" <td>770</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>35-44 years</th>\n", | |
" <td>1972</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>45-54 years</th>\n", | |
" <td>5488</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5-14 years</th>\n", | |
" <td>14</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>55-64 years</th>\n", | |
" <td>13465</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>65-74 years</th>\n", | |
" <td>23333</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>75-84 years</th>\n", | |
" <td>29779</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>85 years and over</th>\n", | |
" <td>37245</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Under 1 year</th>\n", | |
" <td>9</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" COVID-19 Deaths\n", | |
"Age Group \n", | |
"1-4 years 6\n", | |
"15-24 years 142\n", | |
"25-34 years 770\n", | |
"35-44 years 1972\n", | |
"45-54 years 5488\n", | |
"5-14 years 14\n", | |
"55-64 years 13465\n", | |
"65-74 years 23333\n", | |
"75-84 years 29779\n", | |
"85 years and over 37245\n", | |
"Under 1 year 9" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"total_deaths" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def convert_item(row):\n", | |
" if row.name == \"Under 1 year\":\n", | |
" return [0, 0.9]\n", | |
" elif row.name == \"85 years and over\":\n", | |
" return [85, 120]\n", | |
" else:\n", | |
" return [float(item) for item in row.name.replace(\" years\", \"\").split(\"-\")]\n", | |
"\n", | |
"age_groups = total_deaths.apply(convert_item, axis=1)\n", | |
"total_deaths['age_groups'] = age_groups\n", | |
"fixed_index_df = total_deaths.set_index('age_groups')\n", | |
"sorted_df = fixed_index_df.sort_index()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"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>COVID-19 Deaths</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>age_groups</th>\n", | |
" <th></th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>[0, 0.9]</th>\n", | |
" <td>9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[1.0, 4.0]</th>\n", | |
" <td>6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[5.0, 14.0]</th>\n", | |
" <td>14</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[15.0, 24.0]</th>\n", | |
" <td>142</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[25.0, 34.0]</th>\n", | |
" <td>770</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[35.0, 44.0]</th>\n", | |
" <td>1972</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[45.0, 54.0]</th>\n", | |
" <td>5488</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[55.0, 64.0]</th>\n", | |
" <td>13465</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[65.0, 74.0]</th>\n", | |
" <td>23333</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[75.0, 84.0]</th>\n", | |
" <td>29779</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[85, 120]</th>\n", | |
" <td>37245</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" COVID-19 Deaths\n", | |
"age_groups \n", | |
"[0, 0.9] 9\n", | |
"[1.0, 4.0] 6\n", | |
"[5.0, 14.0] 14\n", | |
"[15.0, 24.0] 142\n", | |
"[25.0, 34.0] 770\n", | |
"[35.0, 44.0] 1972\n", | |
"[45.0, 54.0] 5488\n", | |
"[55.0, 64.0] 13465\n", | |
"[65.0, 74.0] 23333\n", | |
"[75.0, 84.0] 29779\n", | |
"[85, 120] 37245" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"sorted_df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"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>% of total deaths</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>age_groups</th>\n", | |
" <th></th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>[0, 0.9]</th>\n", | |
" <td>0.008</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[1.0, 4.0]</th>\n", | |
" <td>0.005</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[5.0, 14.0]</th>\n", | |
" <td>0.012</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[15.0, 24.0]</th>\n", | |
" <td>0.127</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[25.0, 34.0]</th>\n", | |
" <td>0.686</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[35.0, 44.0]</th>\n", | |
" <td>1.757</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[45.0, 54.0]</th>\n", | |
" <td>4.890</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[55.0, 64.0]</th>\n", | |
" <td>11.998</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[65.0, 74.0]</th>\n", | |
" <td>20.792</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[75.0, 84.0]</th>\n", | |
" <td>26.536</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>[85, 120]</th>\n", | |
" <td>33.188</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" % of total deaths\n", | |
"age_groups \n", | |
"[0, 0.9] 0.008\n", | |
"[1.0, 4.0] 0.005\n", | |
"[5.0, 14.0] 0.012\n", | |
"[15.0, 24.0] 0.127\n", | |
"[25.0, 34.0] 0.686\n", | |
"[35.0, 44.0] 1.757\n", | |
"[45.0, 54.0] 4.890\n", | |
"[55.0, 64.0] 11.998\n", | |
"[65.0, 74.0] 20.792\n", | |
"[75.0, 84.0] 26.536\n", | |
"[85, 120] 33.188" | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"percentages = sorted_df.apply(lambda r: round(100*r/r.sum(),3))\n", | |
"percentages.rename(columns={\"COVID-19 Deaths\":\"% of total deaths\"})" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"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>COVID-19 Deaths</th>\n", | |
" <th>age_groups</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Age Group</th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1-4 years</th>\n", | |
" <td>6</td>\n", | |
" <td>[1.0, 4.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15-24 years</th>\n", | |
" <td>142</td>\n", | |
" <td>[15.0, 24.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>25-34 years</th>\n", | |
" <td>770</td>\n", | |
" <td>[25.0, 34.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>35-44 years</th>\n", | |
" <td>1972</td>\n", | |
" <td>[35.0, 44.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>45-54 years</th>\n", | |
" <td>5488</td>\n", | |
" <td>[45.0, 54.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5-14 years</th>\n", | |
" <td>14</td>\n", | |
" <td>[5.0, 14.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>55-64 years</th>\n", | |
" <td>13465</td>\n", | |
" <td>[55.0, 64.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>65-74 years</th>\n", | |
" <td>23333</td>\n", | |
" <td>[65.0, 74.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>75-84 years</th>\n", | |
" <td>29779</td>\n", | |
" <td>[75.0, 84.0]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>85 years and over</th>\n", | |
" <td>37245</td>\n", | |
" <td>[85, 120]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Under 1 year</th>\n", | |
" <td>9</td>\n", | |
" <td>[0, 0.9]</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" COVID-19 Deaths age_groups\n", | |
"Age Group \n", | |
"1-4 years 6 [1.0, 4.0]\n", | |
"15-24 years 142 [15.0, 24.0]\n", | |
"25-34 years 770 [25.0, 34.0]\n", | |
"35-44 years 1972 [35.0, 44.0]\n", | |
"45-54 years 5488 [45.0, 54.0]\n", | |
"5-14 years 14 [5.0, 14.0]\n", | |
"55-64 years 13465 [55.0, 64.0]\n", | |
"65-74 years 23333 [65.0, 74.0]\n", | |
"75-84 years 29779 [75.0, 84.0]\n", | |
"85 years and over 37245 [85, 120]\n", | |
"Under 1 year 9 [0, 0.9]" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"total_deaths" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/svg+xml": [ | |
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"700\" height=\"450\" style=\"\" viewBox=\"0 0 700 450\"><rect x=\"0\" y=\"0\" width=\"700\" height=\"450\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-3d0ed8\"><g class=\"clips\"/><g class=\"gradients\"/></defs><g class=\"bglayer\"/><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"/><g class=\"polarlayer\"/><g class=\"ternarylayer\"/><g class=\"geolayer\"/><g class=\"funnelarealayer\"/><g class=\"pielayer\"><g class=\"trace\" stroke-linejoin=\"round\" style=\"opacity: 1;\"><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l0,-155a155,155 0 0 1 134.93418780750048,231.27427456705303Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(99, 110, 250); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(398.33387400860823,177.5893920667876)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(255, 255, 255); fill-opacity: 1; white-space: pre;\">33.2%</text></g></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l-154.27912935121108,14.931518564174137a155,155 0 0 1 154.27912935121108,-169.93151856417413Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(239, 85, 59); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(260.5608837147614,159.63453456644618)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">26.5%</text></g></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l-25.90808076280027,152.8194076391746a155,155 0 0 1 -128.37104858841082,-137.8878890750005Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(0, 204, 150); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(255.93643528621794,285.1933604191834)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">20.8%</text></g></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l85.71317974852211,129.1443023032667a155,155 0 0 1 -111.62126051132238,23.675105335907915Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(171, 99, 250); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(350.00769748174395,330.33198099445644)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">12%</text></g></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l120.75874250623704,97.17163222006894a155,155 0 0 1 -35.04556275771493,31.972670083197755Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(255, 161, 90); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(403.66841573997056,306.2618592160245)rotate(47.625263983318916)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">4.89%</text></g></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l130.73030431228833,83.27417087198458a155,155 0 0 1 -9.971561806051284,13.897461348084363Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(25, 211, 243); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(476.2801229245963,372.6141768743439)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">1.76%</text></g><path class=\"textline\" stroke-width=\"1.5\" d=\"M452.4363729245963,305.3605554132831V368.1141768743439h3.75\" fill=\"none\" style=\"stroke: rgb(42, 63, 95); stroke-opacity: 1;\"/></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l134.1977638075889,77.56262108156598a155,155 0 0 1 -3.4674594953005737,5.7115497904186014Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(255, 102, 146); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(486.651064123741,357.6141768743439)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">0.686%</text></g><path class=\"textline\" stroke-width=\"1.5\" d=\"M458.994814123741,295.4370824328886V353.1141768743439h3.75\" fill=\"none\" style=\"stroke: rgb(42, 63, 95); stroke-opacity: 1;\"/></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l134.81016625424687,76.4932616280828a155,155 0 0 1 -0.612402446657967,1.0693594534831732Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(182, 232, 128); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(488.6612777552797,342.6141768743439)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">0.127%</text></g><path class=\"textline\" stroke-width=\"1.5\" d=\"M461.0050277552797,292.02854995747634V338.1141768743439h3.75\" fill=\"none\" style=\"stroke: rgb(42, 63, 95); stroke-opacity: 1;\"/></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l134.87008312030974,76.38756887819339a155,155 0 0 1 -0.059916866062877716,0.10569274988941402Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(255, 151, 255); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(492.80888504302084,327.6141768743439)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">0.0125%</text></g><path class=\"textline\" stroke-width=\"1.5\" d=\"M461.34013504302084,291.4404211237739V323.1141768743439h3.75\" fill=\"none\" style=\"stroke: rgb(42, 63, 95); stroke-opacity: 1;\"/></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l134.90855735050448,76.31959875160271a155,155 0 0 1 -0.03847423019473695,0.06797012659068002Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(254, 203, 82); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(496.67057451663754,312.6141768743439)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">0.00802%</text></g><path class=\"textline\" stroke-width=\"1.5\" d=\"M461.38932451663754,291.3535862382721V308.1141768743439h3.75\" fill=\"none\" style=\"stroke: rgb(42, 63, 95); stroke-opacity: 1;\"/></g><g class=\"slice\"><path class=\"surface\" d=\"M326.5,215l134.9341878075004,76.27427456705318a155,155 0 0 1 -0.02563045699591271,0.04532418454952847Z\" style=\"pointer-events: all; stroke-width: 0; fill: rgb(198, 202, 253); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/><g class=\"slicetext\"><text data-notex=\"1\" class=\"slicetext\" transform=\"translate(496.7026244822236,297.6141768743439)\" text-anchor=\"middle\" x=\"0\" y=\"0\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">0.00535%</text></g></g></g></g><g class=\"treemaplayer\"/><g class=\"sunburstlayer\"/><g class=\"glimages\"/><defs id=\"topdefs-3d0ed8\"><g class=\"clips\"/><clipPath id=\"legend3d0ed8\"><rect width=\"88\" height=\"219\" x=\"0\" y=\"0\"/></clipPath></defs><g class=\"layer-above\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"infolayer\"><g class=\"legend\" pointer-events=\"all\" transform=\"translate(574.54, 60)\"><rect class=\"bg\" shape-rendering=\"crispEdges\" width=\"88\" height=\"219\" x=\"0\" y=\"0\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; fill: rgb(255, 255, 255); fill-opacity: 1; stroke-width: 0px;\"/><g class=\"scrollbox\" transform=\"translate(0, 0)\" clip-path=\"url('#legend3d0ed8')\"><g class=\"groups\"><g class=\"traces\" transform=\"translate(0, 14.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">85,120</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(99, 110, 250); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 33.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">75,84</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(239, 85, 59); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 52.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">65,74</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(0, 204, 150); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 71.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">55,64</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(171, 99, 250); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 90.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">45,54</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(255, 161, 90); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 109.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">35,44</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(25, 211, 243); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 128.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">25,34</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(255, 102, 146); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 147.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">15,24</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(182, 232, 128); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 166.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">5,14</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(255, 151, 255); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 185.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">0,0.9</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(254, 203, 82); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g><g class=\"traces\" transform=\"translate(0, 204.5)\" style=\"opacity: 1;\"><text class=\"legendtext user-select-none\" text-anchor=\"start\" x=\"40\" y=\"4.680000000000001\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(42, 63, 95); fill-opacity: 1; white-space: pre;\">1,4</text><g class=\"layers\" style=\"opacity: 1;\"><g class=\"legendfill\"/><g class=\"legendlines\"/><g class=\"legendsymbols\"><g class=\"legendpoints\"><path class=\"legendpie\" d=\"M6,6H-6V-6H6Z\" transform=\"translate(20,0)\" style=\"stroke-width: 0; fill: rgb(198, 202, 253); fill-opacity: 1; stroke: rgb(68, 68, 68); stroke-opacity: 1;\"/></g></g></g><rect class=\"legendtoggle\" pointer-events=\"all\" x=\"0\" y=\"-9.5\" width=\"82.515625\" height=\"19\" style=\"cursor: pointer; fill: rgb(0, 0, 0); fill-opacity: 0;\"/></g></g></g><rect class=\"scrollbar\" rx=\"20\" ry=\"3\" width=\"0\" height=\"0\" x=\"0\" y=\"0\" style=\"fill: rgb(128, 139, 164); fill-opacity: 1;\"/></g><g class=\"g-gtitle\"/></g></svg>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"fig = px.pie(total_deaths, values=\"COVID-19 Deaths\", names=\"age_groups\")\n", | |
"fig.show(renderer=\"svg\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"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.7.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment