You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Data-Science-For-Beginners/2-Working-With-Data/07-python/notebook-covidspread.ipynb

2451 lines
702 KiB

{
"cells": [
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
3 years ago
"# Estimation of COVID-19 Pandemic\n",
"\n",
"## Loading Data\n",
"\n",
"We will use data on COVID-19 infected individuals, provided by the [Center for Systems Science and Engineering](https://systems.jhu.edu/) (CSSE) at [Johns Hopkins University](https://jhu.edu/). Dataset is available in [this GitHub Repository](https://github.com/CSSEGISandData/COVID-19)."
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 124,
3 years ago
"metadata": {},
"outputs": [],
"source": [
3 years ago
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"plt.rcParams[\"figure.figsize\"] = (10,3) # make figures larger"
3 years ago
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"We can load the most recent data directly from GitHub using `pd.read_csv`. If for some reason the data is not available, you can always use the copy available locally in the `data` folder - just uncomment the line below that defines `base_url`:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 125,
3 years ago
"metadata": {},
"outputs": [],
"source": [
3 years ago
"base_url = \"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/\" # loading from Internet\n",
"# base_url = \"../../data/COVID/\" # loading from disk\n",
"infected_dataset_url = base_url + \"time_series_covid19_confirmed_global.csv\"\n",
"recovered_dataset_url = base_url + \"time_series_covid19_recovered_global.csv\"\n",
"deaths_dataset_url = base_url + \"time_series_covid19_deaths_global.csv\"\n",
"countries_dataset_url = base_url + \"../UID_ISO_FIPS_LookUp_Table.csv\""
3 years ago
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"Let's now load the data for infected individuals and see how the data looks like:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 126,
3 years ago
"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>Province/State</th>\n",
" <th>Country/Region</th>\n",
" <th>Lat</th>\n",
" <th>Long</th>\n",
" <th>1/22/20</th>\n",
" <th>1/23/20</th>\n",
" <th>1/24/20</th>\n",
" <th>1/25/20</th>\n",
" <th>1/26/20</th>\n",
" <th>1/27/20</th>\n",
" <th>...</th>\n",
" <th>8/20/21</th>\n",
" <th>8/21/21</th>\n",
" <th>8/22/21</th>\n",
" <th>8/23/21</th>\n",
" <th>8/24/21</th>\n",
" <th>8/25/21</th>\n",
" <th>8/26/21</th>\n",
" <th>8/27/21</th>\n",
" <th>8/28/21</th>\n",
" <th>8/29/21</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>NaN</td>\n",
" <td>Afghanistan</td>\n",
" <td>33.93911</td>\n",
" <td>67.709953</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>152448</td>\n",
" <td>152448</td>\n",
" <td>152448</td>\n",
" <td>152583</td>\n",
" <td>152660</td>\n",
" <td>152722</td>\n",
" <td>152822</td>\n",
" <td>152960</td>\n",
" <td>152960</td>\n",
" <td>152960</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>NaN</td>\n",
" <td>Albania</td>\n",
" <td>41.15330</td>\n",
" <td>20.168300</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>138132</td>\n",
" <td>138790</td>\n",
" <td>139324</td>\n",
" <td>139721</td>\n",
" <td>140521</td>\n",
" <td>141365</td>\n",
" <td>142253</td>\n",
" <td>143174</td>\n",
" <td>144079</td>\n",
" <td>144847</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>NaN</td>\n",
" <td>Algeria</td>\n",
" <td>28.03390</td>\n",
" <td>1.659600</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>190656</td>\n",
" <td>191171</td>\n",
" <td>191583</td>\n",
" <td>192089</td>\n",
" <td>192626</td>\n",
" <td>193171</td>\n",
" <td>193674</td>\n",
" <td>194186</td>\n",
" <td>194671</td>\n",
" <td>195162</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>NaN</td>\n",
" <td>Andorra</td>\n",
" <td>42.50630</td>\n",
" <td>1.521800</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>14988</td>\n",
" <td>14988</td>\n",
" <td>14988</td>\n",
" <td>15002</td>\n",
" <td>15003</td>\n",
" <td>15014</td>\n",
" <td>15016</td>\n",
" <td>15025</td>\n",
" <td>15025</td>\n",
" <td>15025</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>NaN</td>\n",
" <td>Angola</td>\n",
" <td>-11.20270</td>\n",
" <td>17.873900</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>45583</td>\n",
" <td>45817</td>\n",
" <td>45945</td>\n",
" <td>46076</td>\n",
" <td>46340</td>\n",
" <td>46539</td>\n",
" <td>46726</td>\n",
" <td>46929</td>\n",
" <td>47079</td>\n",
" <td>47168</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 590 columns</p>\n",
"</div>"
3 years ago
],
"text/plain": [
" Province/State Country/Region Lat Long 1/22/20 1/23/20 \\\n",
"0 NaN Afghanistan 33.93911 67.709953 0 0 \n",
"1 NaN Albania 41.15330 20.168300 0 0 \n",
"2 NaN Algeria 28.03390 1.659600 0 0 \n",
"3 NaN Andorra 42.50630 1.521800 0 0 \n",
"4 NaN Angola -11.20270 17.873900 0 0 \n",
"\n",
" 1/24/20 1/25/20 1/26/20 1/27/20 ... 8/20/21 8/21/21 8/22/21 \\\n",
"0 0 0 0 0 ... 152448 152448 152448 \n",
"1 0 0 0 0 ... 138132 138790 139324 \n",
"2 0 0 0 0 ... 190656 191171 191583 \n",
"3 0 0 0 0 ... 14988 14988 14988 \n",
"4 0 0 0 0 ... 45583 45817 45945 \n",
"\n",
" 8/23/21 8/24/21 8/25/21 8/26/21 8/27/21 8/28/21 8/29/21 \n",
"0 152583 152660 152722 152822 152960 152960 152960 \n",
"1 139721 140521 141365 142253 143174 144079 144847 \n",
"2 192089 192626 193171 193674 194186 194671 195162 \n",
"3 15002 15003 15014 15016 15025 15025 15025 \n",
"4 46076 46340 46539 46726 46929 47079 47168 \n",
"\n",
"[5 rows x 590 columns]"
]
},
3 years ago
"execution_count": 126,
"metadata": {},
3 years ago
"output_type": "execute_result"
}
],
3 years ago
"source": [
"infected = pd.read_csv(infected_dataset_url)\n",
"infected.head()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"We can see that each row of the table defines the number of infected individuals for each country and/or province, and columns correspond to dates. Similar tables can be loaded for other data, such as number of recovered and number of deaths."
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 127,
3 years ago
"metadata": {},
"outputs": [],
"source": [
3 years ago
"recovered = pd.read_csv(recovered_dataset_url)\n",
"deaths = pd.read_csv(deaths_dataset_url)"
3 years ago
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
3 years ago
"## Making Sense of the Data\n",
"\n",
"From the table above the role of province column is not clear. Let's see the different values that are present in `Province/State` column:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 128,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Australian Capital Territory 1\n",
"Xinjiang 1\n",
"Martinique 1\n",
"Guadeloupe 1\n",
"French Polynesia 1\n",
" ..\n",
"Fujian 1\n",
"Chongqing 1\n",
"Beijing 1\n",
"Anhui 1\n",
"Turks and Caicos Islands 1\n",
"Name: Province/State, Length: 87, dtype: int64"
]
},
3 years ago
"execution_count": 128,
"metadata": {},
3 years ago
"output_type": "execute_result"
}
],
3 years ago
"source": [
"infected['Province/State'].value_counts()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"From the names we can deduce that countries like Australia and China have more detailed breakdown by provinces. Let's look for information on China to see the example:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 129,
3 years ago
"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>Province/State</th>\n",
" <th>Country/Region</th>\n",
" <th>Lat</th>\n",
" <th>Long</th>\n",
" <th>1/22/20</th>\n",
" <th>1/23/20</th>\n",
" <th>1/24/20</th>\n",
" <th>1/25/20</th>\n",
" <th>1/26/20</th>\n",
" <th>1/27/20</th>\n",
" <th>...</th>\n",
" <th>8/20/21</th>\n",
" <th>8/21/21</th>\n",
" <th>8/22/21</th>\n",
" <th>8/23/21</th>\n",
" <th>8/24/21</th>\n",
" <th>8/25/21</th>\n",
" <th>8/26/21</th>\n",
" <th>8/27/21</th>\n",
" <th>8/28/21</th>\n",
" <th>8/29/21</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>58</th>\n",
" <td>Anhui</td>\n",
" <td>China</td>\n",
" <td>31.8257</td>\n",
" <td>117.2264</td>\n",
" <td>1</td>\n",
" <td>9</td>\n",
" <td>15</td>\n",
" <td>39</td>\n",
" <td>60</td>\n",
" <td>70</td>\n",
" <td>...</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" <td>1008</td>\n",
" </tr>\n",
" <tr>\n",
" <th>59</th>\n",
" <td>Beijing</td>\n",
" <td>China</td>\n",
" <td>40.1824</td>\n",
" <td>116.4142</td>\n",
" <td>14</td>\n",
" <td>22</td>\n",
" <td>36</td>\n",
" <td>41</td>\n",
" <td>68</td>\n",
" <td>80</td>\n",
" <td>...</td>\n",
" <td>1112</td>\n",
" <td>1113</td>\n",
" <td>1115</td>\n",
" <td>1115</td>\n",
" <td>1115</td>\n",
" <td>1115</td>\n",
" <td>1115</td>\n",
" <td>1115</td>\n",
" <td>1115</td>\n",
" <td>1115</td>\n",
" </tr>\n",
" <tr>\n",
" <th>60</th>\n",
" <td>Chongqing</td>\n",
" <td>China</td>\n",
" <td>30.0572</td>\n",
" <td>107.8740</td>\n",
" <td>6</td>\n",
" <td>9</td>\n",
" <td>27</td>\n",
" <td>57</td>\n",
" <td>75</td>\n",
" <td>110</td>\n",
" <td>...</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" <td>603</td>\n",
" </tr>\n",
" <tr>\n",
" <th>61</th>\n",
" <td>Fujian</td>\n",
" <td>China</td>\n",
" <td>26.0789</td>\n",
" <td>117.9874</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>10</td>\n",
" <td>18</td>\n",
" <td>35</td>\n",
" <td>59</td>\n",
" <td>...</td>\n",
" <td>780</td>\n",
" <td>780</td>\n",
" <td>780</td>\n",
" <td>782</td>\n",
" <td>782</td>\n",
" <td>783</td>\n",
" <td>783</td>\n",
" <td>784</td>\n",
" <td>785</td>\n",
" <td>786</td>\n",
" </tr>\n",
" <tr>\n",
" <th>62</th>\n",
" <td>Gansu</td>\n",
" <td>China</td>\n",
" <td>35.7518</td>\n",
" <td>104.2861</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" <td>7</td>\n",
" <td>14</td>\n",
" <td>...</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" <td>199</td>\n",
" </tr>\n",
" <tr>\n",
" <th>63</th>\n",
" <td>Guangdong</td>\n",
" <td>China</td>\n",
" <td>23.3417</td>\n",
" <td>113.4244</td>\n",
" <td>26</td>\n",
" <td>32</td>\n",
" <td>53</td>\n",
" <td>78</td>\n",
" <td>111</td>\n",
" <td>151</td>\n",
" <td>...</td>\n",
" <td>3001</td>\n",
" <td>3007</td>\n",
" <td>3012</td>\n",
" <td>3020</td>\n",
" <td>3023</td>\n",
" <td>3032</td>\n",
" <td>3040</td>\n",
" <td>3043</td>\n",
" <td>3046</td>\n",
" <td>3055</td>\n",
" </tr>\n",
" <tr>\n",
" <th>64</th>\n",
" <td>Guangxi</td>\n",
" <td>China</td>\n",
" <td>23.8298</td>\n",
" <td>108.7881</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>23</td>\n",
" <td>23</td>\n",
" <td>36</td>\n",
" <td>46</td>\n",
" <td>...</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" <td>289</td>\n",
" </tr>\n",
" <tr>\n",
" <th>65</th>\n",
" <td>Guizhou</td>\n",
" <td>China</td>\n",
" <td>26.8154</td>\n",
" <td>106.8748</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" <td>...</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" <td>147</td>\n",
" </tr>\n",
" <tr>\n",
" <th>66</th>\n",
" <td>Hainan</td>\n",
" <td>China</td>\n",
" <td>19.1959</td>\n",
" <td>109.7453</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>8</td>\n",
" <td>19</td>\n",
" <td>22</td>\n",
" <td>33</td>\n",
" <td>...</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" <td>190</td>\n",
" </tr>\n",
" <tr>\n",
" <th>67</th>\n",
" <td>Hebei</td>\n",
" <td>China</td>\n",
" <td>39.5490</td>\n",
" <td>116.1306</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>8</td>\n",
" <td>13</td>\n",
" <td>18</td>\n",
" <td>...</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" <td>1317</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68</th>\n",
" <td>Heilongjiang</td>\n",
" <td>China</td>\n",
" <td>47.8620</td>\n",
" <td>127.7615</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" <td>9</td>\n",
" <td>15</td>\n",
" <td>21</td>\n",
" <td>...</td>\n",
" <td>1614</td>\n",
" <td>1614</td>\n",
" <td>1614</td>\n",
" <td>1614</td>\n",
" <td>1614</td>\n",
" <td>1614</td>\n",
" <td>1615</td>\n",
" <td>1615</td>\n",
" <td>1615</td>\n",
" <td>1615</td>\n",
" </tr>\n",
" <tr>\n",
" <th>69</th>\n",
" <td>Henan</td>\n",
" <td>China</td>\n",
" <td>37.8957</td>\n",
" <td>114.9042</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>9</td>\n",
" <td>32</td>\n",
" <td>83</td>\n",
" <td>128</td>\n",
" <td>...</td>\n",
" <td>1521</td>\n",
" <td>1522</td>\n",
" <td>1523</td>\n",
" <td>1524</td>\n",
" <td>1525</td>\n",
" <td>1525</td>\n",
" <td>1527</td>\n",
" <td>1528</td>\n",
" <td>1528</td>\n",
" <td>1528</td>\n",
" </tr>\n",
" <tr>\n",
" <th>70</th>\n",
" <td>Hong Kong</td>\n",
" <td>China</td>\n",
" <td>22.3000</td>\n",
" <td>114.2000</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>8</td>\n",
" <td>8</td>\n",
" <td>...</td>\n",
" <td>12049</td>\n",
" <td>12052</td>\n",
" <td>12057</td>\n",
" <td>12062</td>\n",
" <td>12069</td>\n",
" <td>12074</td>\n",
" <td>12077</td>\n",
" <td>12094</td>\n",
" <td>12100</td>\n",
" <td>12107</td>\n",
" </tr>\n",
" <tr>\n",
" <th>71</th>\n",
" <td>Hubei</td>\n",
" <td>China</td>\n",
" <td>30.9756</td>\n",
" <td>112.2707</td>\n",
" <td>444</td>\n",
" <td>444</td>\n",
" <td>549</td>\n",
" <td>761</td>\n",
" <td>1058</td>\n",
" <td>1423</td>\n",
" <td>...</td>\n",
" <td>68287</td>\n",
" <td>68289</td>\n",
" <td>68289</td>\n",
" <td>68289</td>\n",
" <td>68289</td>\n",
" <td>68289</td>\n",
" <td>68290</td>\n",
" <td>68290</td>\n",
" <td>68290</td>\n",
" <td>68290</td>\n",
" </tr>\n",
" <tr>\n",
" <th>72</th>\n",
" <td>Hunan</td>\n",
" <td>China</td>\n",
" <td>27.6104</td>\n",
" <td>111.7088</td>\n",
" <td>4</td>\n",
" <td>9</td>\n",
" <td>24</td>\n",
" <td>43</td>\n",
" <td>69</td>\n",
" <td>100</td>\n",
" <td>...</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" <td>1181</td>\n",
" </tr>\n",
" <tr>\n",
" <th>73</th>\n",
" <td>Inner Mongolia</td>\n",
" <td>China</td>\n",
" <td>44.0935</td>\n",
" <td>113.9448</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>11</td>\n",
" <td>...</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" <td>412</td>\n",
" </tr>\n",
" <tr>\n",
" <th>74</th>\n",
" <td>Jiangsu</td>\n",
" <td>China</td>\n",
" <td>32.9711</td>\n",
" <td>119.4550</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>9</td>\n",
" <td>18</td>\n",
" <td>33</td>\n",
" <td>47</td>\n",
" <td>...</td>\n",
" <td>1583</td>\n",
" <td>1584</td>\n",
" <td>1584</td>\n",
" <td>1584</td>\n",
" <td>1586</td>\n",
" <td>1586</td>\n",
" <td>1587</td>\n",
" <td>1587</td>\n",
" <td>1589</td>\n",
" <td>1589</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75</th>\n",
" <td>Jiangxi</td>\n",
" <td>China</td>\n",
" <td>27.6140</td>\n",
" <td>115.7221</td>\n",
" <td>2</td>\n",
" <td>7</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>36</td>\n",
" <td>72</td>\n",
" <td>...</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" <td>937</td>\n",
" </tr>\n",
" <tr>\n",
" <th>76</th>\n",
" <td>Jilin</td>\n",
" <td>China</td>\n",
" <td>43.6661</td>\n",
" <td>126.1923</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>6</td>\n",
" <td>...</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" <td>574</td>\n",
" </tr>\n",
" <tr>\n",
" <th>77</th>\n",
" <td>Liaoning</td>\n",
" <td>China</td>\n",
" <td>41.2956</td>\n",
" <td>122.6085</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>17</td>\n",
" <td>21</td>\n",
" <td>27</td>\n",
" <td>...</td>\n",
" <td>443</td>\n",
" <td>443</td>\n",
" <td>443</td>\n",
" <td>443</td>\n",
" <td>443</td>\n",
" <td>444</td>\n",
" <td>445</td>\n",
" <td>446</td>\n",
" <td>446</td>\n",
" <td>446</td>\n",
" </tr>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>Macau</td>\n",
" <td>China</td>\n",
" <td>22.1667</td>\n",
" <td>113.5500</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>6</td>\n",
" <td>...</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" <td>63</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>Ningxia</td>\n",
" <td>China</td>\n",
" <td>37.2692</td>\n",
" <td>106.1655</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>7</td>\n",
" <td>...</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" <td>77</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>Qinghai</td>\n",
" <td>China</td>\n",
" <td>35.7452</td>\n",
" <td>95.9956</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>6</td>\n",
" <td>...</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" <td>18</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>Shaanxi</td>\n",
" <td>China</td>\n",
" <td>35.1917</td>\n",
" <td>108.8701</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>15</td>\n",
" <td>22</td>\n",
" <td>35</td>\n",
" <td>...</td>\n",
" <td>668</td>\n",
" <td>668</td>\n",
" <td>668</td>\n",
" <td>669</td>\n",
" <td>669</td>\n",
" <td>669</td>\n",
" <td>669</td>\n",
" <td>669</td>\n",
" <td>669</td>\n",
" <td>669</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>Shandong</td>\n",
" <td>China</td>\n",
" <td>36.3427</td>\n",
" <td>118.1498</td>\n",
" <td>2</td>\n",
" <td>6</td>\n",
" <td>15</td>\n",
" <td>27</td>\n",
" <td>46</td>\n",
" <td>75</td>\n",
" <td>...</td>\n",
" <td>923</td>\n",
" <td>923</td>\n",
" <td>923</td>\n",
" <td>923</td>\n",
" <td>923</td>\n",
" <td>923</td>\n",
" <td>923</td>\n",
" <td>923</td>\n",
" <td>923</td>\n",
" <td>924</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>Shanghai</td>\n",
" <td>China</td>\n",
" <td>31.2020</td>\n",
" <td>121.4491</td>\n",
" <td>9</td>\n",
" <td>16</td>\n",
" <td>20</td>\n",
" <td>33</td>\n",
" <td>40</td>\n",
" <td>53</td>\n",
" <td>...</td>\n",
" <td>2420</td>\n",
" <td>2432</td>\n",
" <td>2436</td>\n",
" <td>2445</td>\n",
" <td>2451</td>\n",
" <td>2454</td>\n",
" <td>2462</td>\n",
" <td>2466</td>\n",
" <td>2471</td>\n",
" <td>2476</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84</th>\n",
" <td>Shanxi</td>\n",
" <td>China</td>\n",
" <td>37.5777</td>\n",
" <td>112.2922</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>6</td>\n",
" <td>9</td>\n",
" <td>13</td>\n",
" <td>...</td>\n",
" <td>255</td>\n",
" <td>255</td>\n",
" <td>256</td>\n",
" <td>256</td>\n",
" <td>256</td>\n",
" <td>256</td>\n",
" <td>256</td>\n",
" <td>258</td>\n",
" <td>258</td>\n",
" <td>259</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85</th>\n",
" <td>Sichuan</td>\n",
" <td>China</td>\n",
" <td>30.6171</td>\n",
" <td>102.7103</td>\n",
" <td>5</td>\n",
" <td>8</td>\n",
" <td>15</td>\n",
" <td>28</td>\n",
" <td>44</td>\n",
" <td>69</td>\n",
" <td>...</td>\n",
" <td>1181</td>\n",
" <td>1182</td>\n",
" <td>1183</td>\n",
" <td>1185</td>\n",
" <td>1185</td>\n",
" <td>1185</td>\n",
" <td>1186</td>\n",
" <td>1187</td>\n",
" <td>1188</td>\n",
" <td>1188</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86</th>\n",
" <td>Tianjin</td>\n",
" <td>China</td>\n",
" <td>39.3054</td>\n",
" <td>117.3230</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>8</td>\n",
" <td>10</td>\n",
" <td>14</td>\n",
" <td>23</td>\n",
" <td>...</td>\n",
" <td>458</td>\n",
" <td>459</td>\n",
" <td>462</td>\n",
" <td>463</td>\n",
" <td>464</td>\n",
" <td>465</td>\n",
" <td>466</td>\n",
" <td>466</td>\n",
" <td>470</td>\n",
" <td>472</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <td>Tibet</td>\n",
" <td>China</td>\n",
" <td>31.6927</td>\n",
" <td>88.0924</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>Unknown</td>\n",
" <td>China</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>89</th>\n",
" <td>Xinjiang</td>\n",
" <td>China</td>\n",
" <td>41.1129</td>\n",
" <td>85.2401</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>...</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" <td>980</td>\n",
" </tr>\n",
" <tr>\n",
" <th>90</th>\n",
" <td>Yunnan</td>\n",
" <td>China</td>\n",
" <td>24.9740</td>\n",
" <td>101.4870</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>11</td>\n",
" <td>16</td>\n",
" <td>26</td>\n",
" <td>...</td>\n",
" <td>1000</td>\n",
" <td>1007</td>\n",
" <td>1010</td>\n",
" <td>1014</td>\n",
" <td>1021</td>\n",
" <td>1031</td>\n",
" <td>1039</td>\n",
" <td>1047</td>\n",
" <td>1064</td>\n",
" <td>1067</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91</th>\n",
" <td>Zhejiang</td>\n",
" <td>China</td>\n",
" <td>29.1832</td>\n",
" <td>120.0934</td>\n",
" <td>10</td>\n",
" <td>27</td>\n",
" <td>43</td>\n",
" <td>62</td>\n",
" <td>104</td>\n",
" <td>128</td>\n",
" <td>...</td>\n",
" <td>1420</td>\n",
" <td>1420</td>\n",
" <td>1421</td>\n",
" <td>1428</td>\n",
" <td>1428</td>\n",
" <td>1429</td>\n",
" <td>1429</td>\n",
" <td>1429</td>\n",
" <td>1429</td>\n",
" <td>1430</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>34 rows × 590 columns</p>\n",
"</div>"
3 years ago
],
"text/plain": [
3 years ago
" Province/State Country/Region Lat Long 1/22/20 1/23/20 \\\n",
"58 Anhui China 31.8257 117.2264 1 9 \n",
"59 Beijing China 40.1824 116.4142 14 22 \n",
"60 Chongqing China 30.0572 107.8740 6 9 \n",
"61 Fujian China 26.0789 117.9874 1 5 \n",
"62 Gansu China 35.7518 104.2861 0 2 \n",
"63 Guangdong China 23.3417 113.4244 26 32 \n",
"64 Guangxi China 23.8298 108.7881 2 5 \n",
"65 Guizhou China 26.8154 106.8748 1 3 \n",
"66 Hainan China 19.1959 109.7453 4 5 \n",
"67 Hebei China 39.5490 116.1306 1 1 \n",
"68 Heilongjiang China 47.8620 127.7615 0 2 \n",
"69 Henan China 37.8957 114.9042 5 5 \n",
"70 Hong Kong China 22.3000 114.2000 0 2 \n",
"71 Hubei China 30.9756 112.2707 444 444 \n",
"72 Hunan China 27.6104 111.7088 4 9 \n",
"73 Inner Mongolia China 44.0935 113.9448 0 0 \n",
"74 Jiangsu China 32.9711 119.4550 1 5 \n",
"75 Jiangxi China 27.6140 115.7221 2 7 \n",
"76 Jilin China 43.6661 126.1923 0 1 \n",
"77 Liaoning China 41.2956 122.6085 2 3 \n",
"78 Macau China 22.1667 113.5500 1 2 \n",
"79 Ningxia China 37.2692 106.1655 1 1 \n",
"80 Qinghai China 35.7452 95.9956 0 0 \n",
"81 Shaanxi China 35.1917 108.8701 0 3 \n",
"82 Shandong China 36.3427 118.1498 2 6 \n",
"83 Shanghai China 31.2020 121.4491 9 16 \n",
"84 Shanxi China 37.5777 112.2922 1 1 \n",
"85 Sichuan China 30.6171 102.7103 5 8 \n",
"86 Tianjin China 39.3054 117.3230 4 4 \n",
"87 Tibet China 31.6927 88.0924 0 0 \n",
"88 Unknown China NaN NaN 0 0 \n",
"89 Xinjiang China 41.1129 85.2401 0 2 \n",
"90 Yunnan China 24.9740 101.4870 1 2 \n",
"91 Zhejiang China 29.1832 120.0934 10 27 \n",
"\n",
3 years ago
" 1/24/20 1/25/20 1/26/20 1/27/20 ... 8/20/21 8/21/21 8/22/21 \\\n",
"58 15 39 60 70 ... 1008 1008 1008 \n",
"59 36 41 68 80 ... 1112 1113 1115 \n",
"60 27 57 75 110 ... 603 603 603 \n",
"61 10 18 35 59 ... 780 780 780 \n",
"62 2 4 7 14 ... 199 199 199 \n",
"63 53 78 111 151 ... 3001 3007 3012 \n",
"64 23 23 36 46 ... 289 289 289 \n",
"65 3 4 5 7 ... 147 147 147 \n",
"66 8 19 22 33 ... 190 190 190 \n",
"67 2 8 13 18 ... 1317 1317 1317 \n",
"68 4 9 15 21 ... 1614 1614 1614 \n",
"69 9 32 83 128 ... 1521 1522 1523 \n",
"70 2 5 8 8 ... 12049 12052 12057 \n",
"71 549 761 1058 1423 ... 68287 68289 68289 \n",
"72 24 43 69 100 ... 1181 1181 1181 \n",
"73 1 7 7 11 ... 412 412 412 \n",
"74 9 18 33 47 ... 1583 1584 1584 \n",
"75 18 18 36 72 ... 937 937 937 \n",
"76 3 4 4 6 ... 574 574 574 \n",
"77 4 17 21 27 ... 443 443 443 \n",
"78 2 2 5 6 ... 63 63 63 \n",
"79 2 3 4 7 ... 77 77 77 \n",
"80 0 1 1 6 ... 18 18 18 \n",
"81 5 15 22 35 ... 668 668 668 \n",
"82 15 27 46 75 ... 923 923 923 \n",
"83 20 33 40 53 ... 2420 2432 2436 \n",
"84 1 6 9 13 ... 255 255 256 \n",
"85 15 28 44 69 ... 1181 1182 1183 \n",
"86 8 10 14 23 ... 458 459 462 \n",
"87 0 0 0 0 ... 1 1 1 \n",
"88 0 0 0 0 ... 0 0 0 \n",
"89 2 3 4 5 ... 980 980 980 \n",
"90 5 11 16 26 ... 1000 1007 1010 \n",
"91 43 62 104 128 ... 1420 1420 1421 \n",
"\n",
3 years ago
" 8/23/21 8/24/21 8/25/21 8/26/21 8/27/21 8/28/21 8/29/21 \n",
"58 1008 1008 1008 1008 1008 1008 1008 \n",
"59 1115 1115 1115 1115 1115 1115 1115 \n",
"60 603 603 603 603 603 603 603 \n",
"61 782 782 783 783 784 785 786 \n",
"62 199 199 199 199 199 199 199 \n",
"63 3020 3023 3032 3040 3043 3046 3055 \n",
"64 289 289 289 289 289 289 289 \n",
"65 147 147 147 147 147 147 147 \n",
"66 190 190 190 190 190 190 190 \n",
"67 1317 1317 1317 1317 1317 1317 1317 \n",
"68 1614 1614 1614 1615 1615 1615 1615 \n",
"69 1524 1525 1525 1527 1528 1528 1528 \n",
"70 12062 12069 12074 12077 12094 12100 12107 \n",
"71 68289 68289 68289 68290 68290 68290 68290 \n",
"72 1181 1181 1181 1181 1181 1181 1181 \n",
"73 412 412 412 412 412 412 412 \n",
"74 1584 1586 1586 1587 1587 1589 1589 \n",
"75 937 937 937 937 937 937 937 \n",
"76 574 574 574 574 574 574 574 \n",
"77 443 443 444 445 446 446 446 \n",
"78 63 63 63 63 63 63 63 \n",
"79 77 77 77 77 77 77 77 \n",
"80 18 18 18 18 18 18 18 \n",
"81 669 669 669 669 669 669 669 \n",
"82 923 923 923 923 923 923 924 \n",
"83 2445 2451 2454 2462 2466 2471 2476 \n",
"84 256 256 256 256 258 258 259 \n",
"85 1185 1185 1185 1186 1187 1188 1188 \n",
"86 463 464 465 466 466 470 472 \n",
"87 1 1 1 1 1 1 1 \n",
"88 0 0 0 0 0 0 0 \n",
"89 980 980 980 980 980 980 980 \n",
"90 1014 1021 1031 1039 1047 1064 1067 \n",
"91 1428 1428 1429 1429 1429 1429 1430 \n",
"\n",
3 years ago
"[34 rows x 590 columns]"
]
},
"execution_count": 129,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"infected[infected['Country/Region']=='China']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Pre-processing the Data \n",
"\n",
"We are not interested in breaking countries down to further territories, thus we would first get rid of this breakdown and add information on all territories together, to get info for the whole country. This can be done using `groupby`:"
]
},
{
"cell_type": "code",
"execution_count": 130,
"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>Lat</th>\n",
" <th>Long</th>\n",
" <th>1/22/20</th>\n",
" <th>1/23/20</th>\n",
" <th>1/24/20</th>\n",
" <th>1/25/20</th>\n",
" <th>1/26/20</th>\n",
" <th>1/27/20</th>\n",
" <th>1/28/20</th>\n",
" <th>1/29/20</th>\n",
" <th>...</th>\n",
" <th>8/20/21</th>\n",
" <th>8/21/21</th>\n",
" <th>8/22/21</th>\n",
" <th>8/23/21</th>\n",
" <th>8/24/21</th>\n",
" <th>8/25/21</th>\n",
" <th>8/26/21</th>\n",
" <th>8/27/21</th>\n",
" <th>8/28/21</th>\n",
" <th>8/29/21</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Country/Region</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Afghanistan</th>\n",
" <td>33.93911</td>\n",
" <td>67.709953</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>152448</td>\n",
" <td>152448</td>\n",
" <td>152448</td>\n",
" <td>152583</td>\n",
" <td>152660</td>\n",
" <td>152722</td>\n",
" <td>152822</td>\n",
" <td>152960</td>\n",
" <td>152960</td>\n",
" <td>152960</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Albania</th>\n",
" <td>41.15330</td>\n",
" <td>20.168300</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>138132</td>\n",
" <td>138790</td>\n",
" <td>139324</td>\n",
" <td>139721</td>\n",
" <td>140521</td>\n",
" <td>141365</td>\n",
" <td>142253</td>\n",
" <td>143174</td>\n",
" <td>144079</td>\n",
" <td>144847</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Algeria</th>\n",
" <td>28.03390</td>\n",
" <td>1.659600</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>190656</td>\n",
" <td>191171</td>\n",
" <td>191583</td>\n",
" <td>192089</td>\n",
" <td>192626</td>\n",
" <td>193171</td>\n",
" <td>193674</td>\n",
" <td>194186</td>\n",
" <td>194671</td>\n",
" <td>195162</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Andorra</th>\n",
" <td>42.50630</td>\n",
" <td>1.521800</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>14988</td>\n",
" <td>14988</td>\n",
" <td>14988</td>\n",
" <td>15002</td>\n",
" <td>15003</td>\n",
" <td>15014</td>\n",
" <td>15016</td>\n",
" <td>15025</td>\n",
" <td>15025</td>\n",
" <td>15025</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Angola</th>\n",
" <td>-11.20270</td>\n",
" <td>17.873900</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>45583</td>\n",
" <td>45817</td>\n",
" <td>45945</td>\n",
" <td>46076</td>\n",
" <td>46340</td>\n",
" <td>46539</td>\n",
" <td>46726</td>\n",
" <td>46929</td>\n",
" <td>47079</td>\n",
" <td>47168</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 588 columns</p>\n",
"</div>"
3 years ago
],
"text/plain": [
" Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 \\\n",
"Country/Region \n",
"Afghanistan 33.93911 67.709953 0 0 0 0 \n",
"Albania 41.15330 20.168300 0 0 0 0 \n",
"Algeria 28.03390 1.659600 0 0 0 0 \n",
"Andorra 42.50630 1.521800 0 0 0 0 \n",
"Angola -11.20270 17.873900 0 0 0 0 \n",
"\n",
" 1/26/20 1/27/20 1/28/20 1/29/20 ... 8/20/21 8/21/21 \\\n",
"Country/Region ... \n",
"Afghanistan 0 0 0 0 ... 152448 152448 \n",
"Albania 0 0 0 0 ... 138132 138790 \n",
"Algeria 0 0 0 0 ... 190656 191171 \n",
"Andorra 0 0 0 0 ... 14988 14988 \n",
"Angola 0 0 0 0 ... 45583 45817 \n",
"\n",
" 8/22/21 8/23/21 8/24/21 8/25/21 8/26/21 8/27/21 8/28/21 \\\n",
"Country/Region \n",
"Afghanistan 152448 152583 152660 152722 152822 152960 152960 \n",
"Albania 139324 139721 140521 141365 142253 143174 144079 \n",
"Algeria 191583 192089 192626 193171 193674 194186 194671 \n",
"Andorra 14988 15002 15003 15014 15016 15025 15025 \n",
"Angola 45945 46076 46340 46539 46726 46929 47079 \n",
"\n",
" 8/29/21 \n",
"Country/Region \n",
"Afghanistan 152960 \n",
"Albania 144847 \n",
"Algeria 195162 \n",
"Andorra 15025 \n",
"Angola 47168 \n",
"\n",
"[5 rows x 588 columns]"
]
},
3 years ago
"execution_count": 130,
"metadata": {},
3 years ago
"output_type": "execute_result"
}
],
3 years ago
"source": [
"infected = infected.groupby('Country/Region').sum()\n",
"recovered = recovered.groupby('Country/Region').sum()\n",
"deaths = deaths.groupby('Country/Region').sum()\n",
"\n",
"infected.head()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"You can see that due to using `groupby` all DataFrames are now indexed by Country/Region. We can thus access the data for a specific country by using `.loc`:|"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 131,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAy0AAAEhCAYAAAByTU9UAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABFaUlEQVR4nO3dd3xb1cH/8a+85G3H244dZ5AdZ5CEDMKeSViF9gFKQoAuWkYpHYzSh9ERCi1P+zz8CmUGykjLCKQthAbIaAohy1nOTpzEifeUpyxL5/eHbMWKncR2Yku2P+/XSy9Z9557deRjXfmrc8+5FmOMEQAAAAD4qQBfVwAAAAAATobQAgAAAMCvEVoAAAAA+DVCCwAAAAC/RmgBAAAA4NcILQAAAAD8GqEFAAAAgF8jtAAAAADwa4QWAAAAAH6N0AIAAADAr/kstKxevVpXX3210tLSZLFY9MEHH3Rq+8cee0wWi6XNLSIionsqDAAAAMAnfBZaamtrNWHCBD377LNd2v4nP/mJCgoKvG5jxozRN77xjTNcUwAAAAC+5LPQMnv2bP3qV7/S9ddf3+76xsZG/exnP9PAgQMVERGhadOmaeXKlZ71kZGRSklJ8dyKioq0Y8cOfetb3+qhVwAAAACgJwT5ugIncvvtt+vgwYNavHix0tLStGTJEl155ZXatm2bhg8f3qb8Sy+9pBEjRui8887zQW0BAAAAdBe/HIi/f/9+vf3223rnnXd03nnnadiwYfrJT36iWbNm6dVXX21T3m63680336SXBQAAAOiD/LKnZdOmTTLGaMSIEV7L7Xa74uPj25R///33VV1dr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1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"207.996562pt\" version=\"1.1\" viewBox=\"0 0 585.7625 207.996562\" width=\"585.7625pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:16:56.636352</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 207.996562 \r\nL 585.7625 207.996562 \r\nL 585.7625 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 20.5625 184.118437 \r\nL 578.5625 184.118437 \r\nL 578.5625 17.798437 \r\nL 20.5625 17.798437 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"m2e330da247\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"45.926136\" xlink:href=\"#m2e330da247\" y=\"184.118437\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- 1/22/20 -->\r\n <g transform=\"translate(26.651136 198.716875)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 794 531 \r\nL 1825 531 \r\nL 1825 4091 \r\nL 703 3866 \r\nL 703 4441 \r\nL 1819 4666 \r\nL 2450 4666 \r\nL 2450 531 \r\nL 3481 531 \r\nL 3481 0 \r\nL 794 0 \r\nL 794 531 \r\nz\r\n\" id=\"DejaVuSans-31\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 1625 4666 \r\nL 2156 4666 \r\nL 531 -594 \r\nL 0 -594 \r\nL 1625 4666 \r\nz\r\n\" id=\"DejaVuSans-2f\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 1228 531 \r\nL 3431 531 \r\nL 3431 0 \r\nL 469 0 \r\nL 469 531 \r\nQ 828 903 1448 1529 \r\nQ 2069 2156 2228 2338 \r\nQ 2531 2678 2651 2914 \r\nQ 2772 3150 2772 3378 \r\nQ 2772 3750 2511 3984 \r\nQ 2250 4219 1831 4219 \r\nQ 1534 4219 1204 4116 \r\nQ 875 4013 500 3803 \r\nL 500 4441 \r\nQ 881 4594 1212 4672 \r\nQ 1544 4750 1819 4750 \r\nQ 2544 4750 2975 4387 \r\nQ 3406 4025 3406 3419 \r\nQ 3406 3131 3298 2873 \r\nQ 3191 2616 2906 2266 \r\nQ 2828 2175 2409 1742 \r\nQ 1991 1309 1228 531 \r\nz\r\n\" id=\"DejaVuSans-32\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 2034 4250 \r\nQ 1547 4250 1301 3770 \r\nQ 1056 3291 1056 2328 \r\nQ 1056 1369 1301 889 \r\nQ 1547 409 2034 409 \r\nQ 2525 409 2770 889 \r\nQ 3016 1369 3016 2328 \r\nQ 3016 3291 2770 3770 \r\nQ 2525 4250 2034 4250 \r\nz\r\nM 2034 4750 \r\nQ 2819 4750 3233 4129 \r\nQ 3647 3509 3647 2328 \r\nQ 3647 1150 3233 529 \r\nQ 2819 -91 2034 -91 \r\nQ 1250 -91 836 529 \r\nQ 422 1150 422 2328 \r\nQ 422 3509 836 4129 \r\nQ 1250 4750 2034 4750 \r\nz\r\n\" id=\"DejaVuSans-30\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-31\"/>\r\n <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2f\"/>\r\n <use x=\"97.314453\" xlink:href=\"#DejaVuSans-32\"/>\r\n <use x=\"160.9375\" xlink:href=\"#DejaVuSans-32\"/>\r\n <use x=\"224.560547\" xlink:href=\"#DejaVuSans-2f\"/>\r\n <use x=\"258.251953\" xlink:href=\"#DejaVuSans-32\"/>\r\n <use x=\"321.875\" xlink:href=\"#DejaVuSans-30\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"infected.loc['US'][2:].plot()\n",
"recovered.loc['US'][2:].plot()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"> **Note** how we use `[2:]` to remove first two elements of a sequence that contain geolocation of a country. We can also drop those two columns altogether:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 132,
3 years ago
"metadata": {},
"outputs": [],
"source": [
3 years ago
"infected.drop(columns=['Lat','Long'],inplace=True)\n",
"recovered.drop(columns=['Lat','Long'],inplace=True)\n",
"deaths.drop(columns=['Lat','Long'],inplace=True)"
3 years ago
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
3 years ago
"## Investigating the Data\n",
"\n",
"Let's now switch to investigating a specific country. Let's create a frame that contains the data on infections indexed by date:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 133,
3 years ago
"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>infected</th>\n",
" <th>recovered</th>\n",
" <th>deaths</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2020-01-22</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-01-23</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-01-24</th>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-01-25</th>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-01-26</th>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2021-08-25</th>\n",
" <td>38223029</td>\n",
" <td>0</td>\n",
" <td>632272</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2021-08-26</th>\n",
" <td>38384360</td>\n",
" <td>0</td>\n",
" <td>633564</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2021-08-27</th>\n",
" <td>38707294</td>\n",
" <td>0</td>\n",
" <td>636720</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2021-08-28</th>\n",
" <td>38760363</td>\n",
" <td>0</td>\n",
" <td>637254</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2021-08-29</th>\n",
" <td>38796746</td>\n",
" <td>0</td>\n",
" <td>637531</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>586 rows × 3 columns</p>\n",
"</div>"
3 years ago
],
"text/plain": [
" infected recovered deaths\n",
"2020-01-22 1 0 0\n",
"2020-01-23 1 0 0\n",
"2020-01-24 2 0 0\n",
"2020-01-25 2 0 0\n",
"2020-01-26 5 0 0\n",
"... ... ... ...\n",
"2021-08-25 38223029 0 632272\n",
"2021-08-26 38384360 0 633564\n",
"2021-08-27 38707294 0 636720\n",
"2021-08-28 38760363 0 637254\n",
"2021-08-29 38796746 0 637531\n",
"\n",
"[586 rows x 3 columns]"
]
},
3 years ago
"execution_count": 133,
"metadata": {},
3 years ago
"output_type": "execute_result"
}
],
3 years ago
"source": [
"def mkframe(country):\n",
" df = pd.DataFrame({ 'infected' : infected.loc[country] ,\n",
" 'recovered' : recovered.loc[country],\n",
" 'deaths' : deaths.loc[country]})\n",
" df.index = pd.to_datetime(df.index)\n",
" return df\n",
"\n",
"df = mkframe('US')\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 134,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAy0AAAEyCAYAAAD3Dz9hAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABSgElEQVR4nO3deWDT9f3H8WeSNm3T+z5oy33fIAIqAhMFPOY9pyh4bjp0MC+mblO82O/n8Nj86byGuuFQf4pzup+KKKAiiijIWa5y9j7TM22T7++PtKEntNA2aft6uCzJ93wnAZLX9/P5fL8mwzAMREREREREfJTZ2wWIiIiIiIgcj0KLiIiIiIj4NIUWERERERHxaQotIiIiIiLi0xRaRERERETEpym0iIiIiIiIT1NoERERERERn6bQIiIiIiIiPk2hRUREREREfJpCi4iIiIiI+DSvhZZ169Zx0UUXkZSUhMlk4r333mvT+g899BAmk6nJLTg4uGMKFhERERERr/BaaCkrK2P06NE8++yzJ7X+3XffTWZmZoPbsGHDuPLKK9u5UhERERER8SavhZbZs2fz6KOPctlllzU7v6qqinvvvZdevXoRHBzMxIkTWbNmjWd+SEgICQkJnlt2djY7duzgpptu6qRXICIiIiIincHP2wW05IYbbuDAgQOsWLGCpKQkVq5cyaxZs9i6dSsDBw5ssvzLL7/MoEGDmDJliheqFRERERGRjuKTA/H37dvHP//5T95++22mTJlC//79ufvuuznrrLNYtmxZk+UdDgfLly9XK4uIiIiISDfkky0t33//PYZhMGjQoAbTHQ4H0dHRTZZ/9913KSkpYe7cuZ1VooiIiIiIdBKfDC0ulwuLxcKmTZuwWCwN5oWEhDRZ/uWXX+bCCy8kISGhs0oUEREREZFO4pOhZezYsTidTnJyck44RiU9PZ3PP/+c999/v5OqExERERGRzuS10FJaWsrevXs9z9PT09m8eTNRUVEMGjSIOXPmMHfuXJYuXcrYsWPJy8vjs88+Y+TIkZx//vme9f72t7+RmJjI7NmzvfEyRERERESkg5kMwzC8seM1a9Ywffr0JtPnzZvHq6++SnV1NY8++iivv/46R48eJTo6msmTJ7N48WJGjhwJuLuR9e7dm7lz5/LYY4919ksQEREREZFO4LXQIiIiIiIi0ho+ecpjERERERGROgotIiIiIiLi0zp9IL7L5SIjI4PQ0FBMJlNn715ERERERHyEYRiUlJSQlJSE2dxye8ophZYlS5Zw//33s2DBAp5++ulWrZORkUFKSsqp7FZERERERLqRw4cPk5yc3OL8kw4tGzdu5MUXX2TUqFFtWi80NNRTWFhY2MnuXkREREREuji73U5KSoonI7TkpEJLaWkpc+bM4aWXXuLRRx9t07p1XcLCwsIUWkRERERE5ITDRk5qIP78+fO54IILmDFjxgmXdTgc2O32BjcREREREZHWanNLy4oVK9i0aRPfffddq5ZfsmQJixcvbnNhIiIiIiIi0MaWlsOHD7NgwQKWL19OYGBgq9a57777KC4u9twOHz58UoWKiIiIiEjPZDIMw2jtwu+99x6XXnopFovFM83pdGIymTCbzTgcjgbzmmO32wkPD6e4uLjFMS0ul4uqqqrWliVdgNVqPe5p7ERERESk52lNNoA2dg8755xz2Lp1a4NpN9xwA0OGDGHRokUnDCytUVVVRXp6Oi6X65S3Jb7DbDbTt29frFart0sRERERkS6mTaElNDSUESNGNJgWHBxMdHR0k+knwzAMMjMzsVgspKSk6Mh8N1F3QdHMzExSU1N1UVERERERaZNTurhke6upqaG8vJykpCRsNpu3y5F2FBsbS0ZGBjU1Nfj7+3u7HBERERHxEsMwyClxsCPTzg97M1q1zimHljVr1pzqJjycTieAuhB1Q3WfqdPpVGgRERER6aGKy6uZu+xbthwuAsDlKG/Vej7Z/0rdh7offaYiIiIiPZthGNz19ha2HC7CbIL+scHMGh7fqnV9qnuYiIiIiIh0P5nFFfxu5TZW78rBajHzzm1nMDI5HLvdzku3nHh9n2xp6WqmTZvGwoULW738rl27mDRpEoGBgYwZM6bD6jpZJpOJ9957z9tliIiIiEgXV1nt5C+r9/CTP631BJY/Xj6SkcnhbdqOWlrawbvvvtumcRoPPvggwcHBpKWlERIS0i41mEwmVq5cySWXXNIu2xMRERERORVbjxRz2/JNHCmsAGB870iWXDaSQfGhbd6WQks7iIqKatPy+/bt44ILLqB3794dVJGIiIiISOcrrqjm2/QCdmbaeXHdfkodNSSGB/Lb2UP46eikkx7nrO5h7aB+97A+ffrw+OOPc+ONNxIaGkpqaiovvviiZ1mTycSmTZt4+OGHMZlMPPTQQwAcPXqUq666isjISKKjo7n44os5cOBAg/387W9/Y/jw4QQEBJCYmMjtt9/u2SfApZdeislk8jwH+Pe//8348eMJDAykX79+LF68mJqaGs/8PXv2cPbZZxMYGMiwYcNYtWpVu78/IiIiItL9rdudy6THV3PL69/x5KrdlDpqmNg3ik9+czYXj+l1Sidm8umWFsMwqK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DPPJCAggMjISP7whz9w4YUXkpKSwpVXXonZbObHH39k69atPProo8yYMYPBgwczd+5cli5dit1u54EHHvDyuyEiIiIiviTHXsnVL24go7jSMy0+LIAXrjuNMSkRnVKDTnnsA2w2G+vWrSM1NZXLLruMoUOHcuONN1JRUeFpeZk3bx5PP/00zz33HMOHD+fCCy9kz549nm0sXbqUVatWkZKSwtixYwGYOXMmH3zwAatWrWLChAlMmjSJJ5980nN9GLPZzMqVK3E4HJx++uncfPPNDca/iIiIiEjPZRgGn2zP4ucvuQNLv9hgnvn5GD789Vmsu3d6pwUWAJPR3MCGDmS
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"219.194375pt\" version=\"1.1\" viewBox=\"0 0 585.7625 219.194375\" width=\"585.7625pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:16:57.262306</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 219.194375 \r\nL 585.7625 219.194375 \r\nL 585.7625 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 20.5625 184.118437 \r\nL 578.5625 184.118437 \r\nL 578.5625 17.798437 \r\nL 20.5625 17.798437 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"m831fc4c288\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"20.5625\" xlink:href=\"#m831fc4c288\" y=\"184.118437\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"87.331731\" xlink:href=\"#m831fc4c288\" y=\"184.118437\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- Apr -->\r\n <g transform=\"translate(78.681731 198.716875)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 2188 4044 \r\nL 1331 1722 \r\nL 3047 1722 \r\nL 2188 4044 \r\nz\r\nM 1831 4666 \r\nL 2547 4666 \r\nL 4325 0 \r\nL 3669 0 \r\nL 3244 1197 \r\nL 1141 1197 \r\nL 716 0 \r\nL 50 0 \r\nL 1831 4666 \r\nz\r\n\" id=\"DejaVuSans-41\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 1159 525 \r\nL 1159 -1331 \r\nL 581 -1331 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2969 \r\nQ 1341 3281 1617 3432 \r\nQ 1894 3584 2278 3584 \r\nQ 2916 3584 3314 3078 \r\nQ 3713 2572 3713 1747 \r\nQ 3713 922 3314 415 \r\nQ 2916 -91 2278 -91 \r\nQ 1894 -91 1617 61 \r\nQ 1341 213 1159 525 \r\nz\r\nM 3116 1747 \r\nQ 3116 2381 2855 2742 \r\nQ 2594 3103 2138 3103 \r\nQ 1681 3103 1420 2742 \r\nQ 1159 2381 1159 1747 \r\nQ 1159 1113 1420 752 \r\nQ 1681 391 2138 391 \r\nQ 2594 391 2855 752 \r\nQ 3116 1113 3116 1747 \r\nz\r\n\" id=\"DejaVuSans-70\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 2631 2963 \r\nQ 2534 3019 2420 3045 \r\nQ 2306 3072 2169 3072 \r\nQ 1681 3072 1420 2755 \r\nQ 1159 2438 1159 1844 \r\nL 1159 0 \r\nL 581 0 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2956 \r\nQ 1341 3275 1631 3429 \r\nQ 1922 3584 2338 3584 \r\nQ 2397 3584 2469 3576 \r\nQ 2541 3569 2628 3553 \r\nL 2631 2963 \r\nz\r\n\" id=\"DejaVuSans-72\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-41\"/>\r\n <use x=\"68.408203\" xlink:href=\"#DejaVuSans-70\"/>\r\n <use x=\"131.884766\" xlink:href=\"#DejaVuSans-72\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_3\">\r\n <g id=\"line2d_3\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"174.131731\" xlink:href=\"#m831fc4c288\" y=\"184.118437\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_2\">\r\n <!-- Jul -->\r\n <g transform=\"translate(168.098918 198.716875)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 466
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"df.plot()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"Now let's compute the number of new infected people each day. This will allow us to see the speed at which pandemic progresses. The easiest day to do it is to use `diff`:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 135,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAEiCAYAAAALexgYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAACkiklEQVR4nOydeXxU9bn/P2f2rJONbJCwE5YEVFA2ZVEIUIFS22JLTaW1aBW1FKyt19tb6q+C1yr2XqzWq1ZUUGxVbAWNQWQRISyBCGGHJGTfk5lkMvuc3x9nzplzzpyZTCA7z/v14mVmznfOnJmYmfM5n+f5PAzLsiwIgiAIgiAIgiCILkHV2wdAEARBEARBEAQxkCCRRRAEQRAEQRAE0YWQyCIIgiAIgiAIguhCSGQRBEEQBEEQBEF0ISSyCIIgCIIgCIIguhASWQRBEARBEARBEF0IiSyCIAiCIAiCIIguRNPbB9DX8Xg8qKqqQlRUFBiG6e3DIQiCIAiCIAiil2BZFq2trUhNTYVKFdivIpHVAVVVVUhLS+vtwyAIgiAIgiAIoo9QXl6OIUOGBNxOIqsDoqKiAHBvZHR0dC8fDUEQBEEQBEEQvYXZbEZaWpqgEQJBIqsD+BLB6OhoElkEQRAEQRAEQXTYRkTBFwRBEARBEARBEF0IiSyCIAiCIAiCIIguhEQWQRAEQRAEQRBEF0IiiyAIgiAIgiAIogshkUUQBEEQBEEQBNGFkMgiCIIgCIIgCILoQkhkEQRBEARBEARBBKDaZMW/CivhcntCfgzNySIIgiAIgiAIggjAs7vOYeepakTqNbh1cFhIjyEniyAIgiAIgiCIG5J2hwsmqzPomuZ2BwCgpT34OjEksgiCIAiCIAiCuCFZsvkg7nxhH+wud8A1bg8LAPCwbMj7JZFFEARBEARBEMQNB8uyuFJvQaPFEdTN8nj49aHvm0QWQRAEQ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+7Cli1boFarhTXbtm3D448/LqQQLl26FC+//LKwXa1WY9euXXjkkUcwc+ZMhIWFYcWKFXjhhReENUajEbt378bq1asxZcoUxMbGYu3atVi7dm1nXjJBEARBEEEQerIUygXrWm3Cz2E6td92giCI7uJkWTOe+/w8bk6PwY5HZiqukTpZgfflvoZ0wU6JrDfffDPodoZhsH79eqxfvz7gGoPBgM2bN2Pz5s0B18TFxWHr1q1Bnys9PR07d+4MuiYrKwsHDhwIuoYgCIIgiGuHP0lRKhesarEKP7fbXT12TARBEG3ez5x2uzvgGskw4gAqi2XZaxpGfN09WQRBEARB3LgEKxesaPaJrFYbiSyCIHqOUGZbeUJwssT392jwBUEQBEEQNy7BygUrRU6WmUQWQRA9CH/dJ/iQYfHPyutCnaUlh0QWQRAEQRDXDD+MWKlcsFLiZDl77JgIgiB8A4Q7XgMEFlmeEEoKlSCRRRAEQRDENcOfcyiVC5KTRRBEbxFSuSDbcbmgK8RwDDkksgiCIAiCuGZ4J0tpGLE4+IKcLIIgepJQwipCcbJCnaUlh0QWQRAEQRDXDD8/xiFzsliWlZULkpNFEETPEYqT5Q5hTpbH0/EaJUhkEQRBEARxzQTqyTJbXbA4fNHJrTZnp05QCIIgrgfByQpiZUnSBf0rnrn9iIVYJ56fRBZBEARBENcMr63k5YL1bdwgYp2aO9XwsJCILoIgiO6EygUJgiAIgui3uL2Xf+XlgvWtDgDAkLgwaFQMAOrLIgii5+iq4As3BV8QBEEQBNHT8Mlb8nLBhjY7ACAhUo8ogwYA9WURBNFz+OZkBV4j3haonNlNPVkEQRAEQfQ0fE+DvFyQF1mDIvWIMmgBkJNFEETPwfdSBRNGobhU0jlZoT8/iSyCIAiCIK4
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"208.595938pt\" version=\"1.1\" viewBox=\"0 0 617.575 208.595938\" width=\"617.575pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:16:57.765311</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 208.595938 \r\nL 617.575 208.595938 \r\nL 617.575 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 52.375 173.52 \r\nL 610.375 173.52 \r\nL 610.375 7.2 \r\nL 52.375 7.2 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"m7c14bc935e\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"52.375\" xlink:href=\"#m7c14bc935e\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"119.144231\" xlink:href=\"#m7c14bc935e\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- Apr -->\r\n <g transform=\"translate(110.494231 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 2188 4044 \r\nL 1331 1722 \r\nL 3047 1722 \r\nL 2188 4044 \r\nz\r\nM 1831 4666 \r\nL 2547 4666 \r\nL 4325 0 \r\nL 3669 0 \r\nL 3244 1197 \r\nL 1141 1197 \r\nL 716 0 \r\nL 50 0 \r\nL 1831 4666 \r\nz\r\n\" id=\"DejaVuSans-41\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 1159 525 \r\nL 1159 -1331 \r\nL 581 -1331 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2969 \r\nQ 1341 3281 1617 3432 \r\nQ 1894 3584 2278 3584 \r\nQ 2916 3584 3314 3078 \r\nQ 3713 2572 3713 1747 \r\nQ 3713 922 3314 415 \r\nQ 2916 -91 2278 -91 \r\nQ 1894 -91 1617 61 \r\nQ 1341 213 1159 525 \r\nz\r\nM 3116 1747 \r\nQ 3116 2381 2855 2742 \r\nQ 2594 3103 2138 3103 \r\nQ 1681 3103 1420 2742 \r\nQ 1159 2381 1159 1747 \r\nQ 1159 1113 1420 752 \r\nQ 1681 391 2138 391 \r\nQ 2594 391 2855 752 \r\nQ 3116 1113 3116 1747 \r\nz\r\n\" id=\"DejaVuSans-70\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 2631 2963 \r\nQ 2534 3019 2420 3045 \r\nQ 2306 3072 2169 3072 \r\nQ 1681 3072 1420 2755 \r\nQ 1159 2438 1159 1844 \r\nL 1159 0 \r\nL 581 0 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2956 \r\nQ 1341 3275 1631 3429 \r\nQ 1922 3584 2338 3584 \r\nQ 2397 3584 2469 3576 \r\nQ 2541 3569 2628 3553 \r\nL 2631 2963 \r\nz\r\n\" id=\"DejaVuSans-72\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-41\"/>\r\n <use x=\"68.408203\" xlink:href=\"#DejaVuSans-70\"/>\r\n <use x=\"131.884766\" xlink:href=\"#DejaVuSans-72\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_3\">\r\n <g id=\"line2d_3\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"205.944231\" xlink:href=\"#m7c14bc935e\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_2\">\r\n <!-- Jul -->\r\n <g transform=\"translate(199.911418 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 4666 \r\nL 1259 4666 \r\nL 1259 325 \r\nQ
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"df['ninfected'] = df['infected'].diff()\n",
"df['ninfected'].plot()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"We can see high fluctuations in data. Let's look closer at one of the months:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 136,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1EAAAFDCAYAAADbBIQTAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB7M0lEQVR4nO3deVzU5fr/8dcw7AgDiIAo7oIirrhbuaRouWSLpibpyaxOpcfS6nTO9/xOZ8vTYnXKVo+nxbXFrMwyt7RMcUFRcd8BWUUYNllnfn+gU7ijwLC8n4/HPLL53PP5XIMIc32u+75ug9VqtSIiIiIiIiLXxcHeAYiIiIiIiNQmSqJERERERE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dB7rh7OjA6v2pTPzvVrLyi+wSi8jNij6ewf/7Og6AmUNCGBYeCICHiyMP9SurRr29/igWVaOknlASJSIidcrRtBzb+oyZQ0LsGsuw8MYseKgnnq6O7Di/KW96TqFdYxKpqISz+fx+YQwlFisjOwfx5PnpqhdM6tOCBi6OHErNYe2BVDtFKVK9lESJiEid8vqaI1isEBkWQOdgb3uHQ69WDfn8sT4EeLlwJC2Xt9YfsXdIItctp6CYKR9vJzO/mI5NTLx8b6dLpsea3J2I6tMcgLd/PKpmKlIvKIkSEZE6I+60mZV7kzEYyvaFqinaBXoxZ0wXAL7ceZrcwhL7BiRyHUotVp76NJbDqbn4e7ow78HuuDkbLzt2yi0tcXVyYHeimZ+PnKnmSMVerFYrx9Jz62XirCRKRETqjNf
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"230.991563pt\" version=\"1.1\" viewBox=\"0 0 611.2125 230.991563\" width=\"611.2125pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:16:58.275352</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 230.991563 \r\nL 611.2125 230.991563 \r\nL 611.2125 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 46.0125 173.52 \r\nL 604.0125 173.52 \r\nL 604.0125 7.2 \r\nL 46.0125 7.2 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"mf8102f31ba\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.0125\" xlink:href=\"#mf8102f31ba\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- -->\r\n <g transform=\"translate(46.0125 188.118438)scale(0.1 -0.1)\"/>\r\n <!-- -->\r\n <g transform=\"translate(46.0125 199.31625)scale(0.1 -0.1)\"/>\r\n <!-- Jul -->\r\n <g transform=\"translate(39.979688 210.514063)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 4666 \r\nL 1259 4666 \r\nL 1259 325 \r\nQ 1259 -519 939 -900 \r\nQ 619 -1281 -91 -1281 \r\nL -331 -1281 \r\nL -331 -750 \r\nL -134 -750 \r\nQ 284 -750 456 -515 \r\nQ 628 -281 628 325 \r\nL 628 4666 \r\nz\r\n\" id=\"DejaVuSans-4a\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 544 1381 \r\nL 544 3500 \r\nL 1119 3500 \r\nL 1119 1403 \r\nQ 1119 906 1312 657 \r\nQ 1506 409 1894 409 \r\nQ 2359 409 2629 706 \r\nQ 2900 1003 2900 1516 \r\nL 2900 3500 \r\nL 3475 3500 \r\nL 3475 0 \r\nL 2900 0 \r\nL 2900 538 \r\nQ 2691 219 2414 64 \r\nQ 2138 -91 1772 -91 \r\nQ 1169 -91 856 284 \r\nQ 544 659 544 1381 \r\nz\r\nM 1991 3584 \r\nL 1991 3584 \r\nz\r\n\" id=\"DejaVuSans-75\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 603 4863 \r\nL 1178 4863 \r\nL 1178 0 \r\nL 603 0 \r\nL 603 4863 \r\nz\r\n\" id=\"DejaVuSans-6c\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-4a\"/>\r\n <use x=\"29.492188\" xlink:href=\"#DejaVuSans-75\"/>\r\n <use x=\"92.871094\" xlink:href=\"#DejaVuSans-6c\"/>\r\n </g>\r\n <!-- 2020 -->\r\n <g transform=\"translate(33.2875 221.711875)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 1228 531 \r\nL 3431 531 \r\nL 3431 0 \r\nL 469 0 \r\nL 469 531 \r\nQ 828 903 1448 1529 \r\nQ 2069 2156 2228 2338 \r\nQ 2531 2678 2651 2914 \r\nQ 2772 3150 2772 3378 \r\nQ 2772 3750 2511 3984 \r\nQ 2250 4219 1831 4219 \r\nQ 1534 4219 1204 4116 \r\nQ 875 4013 500 3803 \r\nL 500 4441 \r\nQ 881 4594 1212 4672 \r\nQ 1544 4750 1819 4750 \r\nQ 2544 4750 2975 4387 \r\nQ 3406 4025 3406 3419 \r\nQ 3406 3131 3298 2873 \r\nQ 3191 2616 2906 2266 \r\nQ 2828 2175 2409 1742 \r\nQ 1991 1309 1228 531 \r\nz\r\n\" id=\"DejaVuSans-32\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 2034 4250 \r\nQ 1547 4250 1301 3770 \r\nQ 1056 3291 1056 2328 \r\nQ 1056 1369 1301 889 \r\nQ 1547 409 2034 409 \r\nQ 2525 409 2770 889 \r\nQ 3016 1369 3016
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"df[(df.index.year==2020) & (df.index.month==7)]['ninfected'].plot()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"It clearly looks like there are weekly fluctuations in data. Because we want to be able to see the trends, it makes sense to smooth out the curve by computing running average (i.e. for each day we will compute the average value of the previous several days):"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 137,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAEiCAYAAAALexgYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABpp0lEQVR4nO3deXiU5fn28e9kkkwWkiEhGwkh7GvYZF8UUAlYQFErVipKa6mtiqVobW1/b6tWxbaobbXuKC4orriBCKKASMISiRD2PQlJSMgy2SfJzPP+ETIa2RKYZLKcn+PIIZnnnplrJiYz59z3c90mwzAMRERERERExC28PF2AiIiIiIhIa6KQJSIiIiIi4kYKWSIiIiIiIm6kkCUiIiIiIuJGClkiIiIiIiJupJAlIiIiIiLiRgpZIiIiIiIibuTt6QKaO6fTSWZmJkFBQZhMJk+XIyIiIiIiHmIYBsXFxURHR+Pldfb5KoWs88jMzCQ2NtbTZYiIiIiISDORnp5Op06dznpcIes8goKCgJonMjg42MPViIiIiIiIpxQVFREbG+vKCGejkHUetUsEg4ODFbJEREREROS8pxGp8YWIiIiIiIgbKWSJiIiIiIi4kUKWiIiIiIiIGylkiYiIiIiIuJFCloiIiIiIiBs1KGQtXLiQ4cOHExQUREREBDNmzGDfvn11xsyZMweTyVTna9SoUXXG2O125s2bR1hYGIGBgVx99dVkZGTUGVNQUMDs2bOxWq1YrVZmz55NYWFhnTFpaWlMnz6dwMBAwsLCuPvuu6msr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ding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"208.595938pt\" version=\"1.1\" viewBox=\"0 0 617.575 208.595938\" width=\"617.575pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:16:58.738817</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 208.595938 \r\nL 617.575 208.595938 \r\nL 617.575 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 52.375 173.52 \r\nL 610.375 173.52 \r\nL 610.375 7.2 \r\nL 52.375 7.2 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"mcb6711831f\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"52.375\" xlink:href=\"#mcb6711831f\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"119.144231\" xlink:href=\"#mcb6711831f\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- Apr -->\r\n <g transform=\"translate(110.494231 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 2188 4044 \r\nL 1331 1722 \r\nL 3047 1722 \r\nL 2188 4044 \r\nz\r\nM 1831 4666 \r\nL 2547 4666 \r\nL 4325 0 \r\nL 3669 0 \r\nL 3244 1197 \r\nL 1141 1197 \r\nL 716 0 \r\nL 50 0 \r\nL 1831 4666 \r\nz\r\n\" id=\"DejaVuSans-41\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 1159 525 \r\nL 1159 -1331 \r\nL 581 -1331 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2969 \r\nQ 1341 3281 1617 3432 \r\nQ 1894 3584 2278 3584 \r\nQ 2916 3584 3314 3078 \r\nQ 3713 2572 3713 1747 \r\nQ 3713 922 3314 415 \r\nQ 2916 -91 2278 -91 \r\nQ 1894 -91 1617 61 \r\nQ 1341 213 1159 525 \r\nz\r\nM 3116 1747 \r\nQ 3116 2381 2855 2742 \r\nQ 2594 3103 2138 3103 \r\nQ 1681 3103 1420 2742 \r\nQ 1159 2381 1159 1747 \r\nQ 1159 1113 1420 752 \r\nQ 1681 391 2138 391 \r\nQ 2594 391 2855 752 \r\nQ 3116 1113 3116 1747 \r\nz\r\n\" id=\"DejaVuSans-70\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 2631 2963 \r\nQ 2534 3019 2420 3045 \r\nQ 2306 3072 2169 3072 \r\nQ 1681 3072 1420 2755 \r\nQ 1159 2438 1159 1844 \r\nL 1159 0 \r\nL 581 0 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2956 \r\nQ 1341 3275 1631 3429 \r\nQ 1922 3584 2338 3584 \r\nQ 2397 3584 2469 3576 \r\nQ 2541 3569 2628 3553 \r\nL 2631 2963 \r\nz\r\n\" id=\"DejaVuSans-72\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-41\"/>\r\n <use x=\"68.408203\" xlink:href=\"#DejaVuSans-70\"/>\r\n <use x=\"131.884766\" xlink:href=\"#DejaVuSans-72\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_3\">\r\n <g id=\"line2d_3\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"205.944231\" xlink:href=\"#mcb6711831f\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_2\">\r\n <!-- Jul -->\r\n <g transform=\"translate(199.911418 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 4666 \r\nL 1259 4666 \r\nL 1259 325 \r\nQ
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"df['ninfav'] = df['ninfected'].rolling(window=7).mean()\n",
"df['ninfav'].plot()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"In order to be able to compare several countries, we might want to take the country's population into account, and compare the percentage of infected individuals with respect to country's population. In order to get country's population, let's load the dataset of countries:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 138,
3 years ago
"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>UID</th>\n",
" <th>iso2</th>\n",
" <th>iso3</th>\n",
" <th>code3</th>\n",
" <th>FIPS</th>\n",
" <th>Admin2</th>\n",
" <th>Province_State</th>\n",
" <th>Country_Region</th>\n",
" <th>Lat</th>\n",
" <th>Long_</th>\n",
" <th>Combined_Key</th>\n",
" <th>Population</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4</td>\n",
" <td>AF</td>\n",
" <td>AFG</td>\n",
" <td>4.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Afghanistan</td>\n",
" <td>33.939110</td>\n",
" <td>67.709953</td>\n",
" <td>Afghanistan</td>\n",
" <td>38928341.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>8</td>\n",
" <td>AL</td>\n",
" <td>ALB</td>\n",
" <td>8.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Albania</td>\n",
" <td>41.153300</td>\n",
" <td>20.168300</td>\n",
" <td>Albania</td>\n",
" <td>2877800.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>12</td>\n",
" <td>DZ</td>\n",
" <td>DZA</td>\n",
" <td>12.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Algeria</td>\n",
" <td>28.033900</td>\n",
" <td>1.659600</td>\n",
" <td>Algeria</td>\n",
" <td>43851043.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>20</td>\n",
" <td>AD</td>\n",
" <td>AND</td>\n",
" <td>20.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Andorra</td>\n",
" <td>42.506300</td>\n",
" <td>1.521800</td>\n",
" <td>Andorra</td>\n",
" <td>77265.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>24</td>\n",
" <td>AO</td>\n",
" <td>AGO</td>\n",
" <td>24.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Angola</td>\n",
" <td>-11.202700</td>\n",
" <td>17.873900</td>\n",
" <td>Angola</td>\n",
" <td>32866268.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",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4191</th>\n",
" <td>84056037</td>\n",
" <td>US</td>\n",
" <td>USA</td>\n",
" <td>840.0</td>\n",
" <td>56037.0</td>\n",
" <td>Sweetwater</td>\n",
" <td>Wyoming</td>\n",
" <td>US</td>\n",
" <td>41.659439</td>\n",
" <td>-108.882788</td>\n",
" <td>Sweetwater, Wyoming, US</td>\n",
" <td>42343.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4192</th>\n",
" <td>84056039</td>\n",
" <td>US</td>\n",
" <td>USA</td>\n",
" <td>840.0</td>\n",
" <td>56039.0</td>\n",
" <td>Teton</td>\n",
" <td>Wyoming</td>\n",
" <td>US</td>\n",
" <td>43.935225</td>\n",
" <td>-110.589080</td>\n",
" <td>Teton, Wyoming, US</td>\n",
" <td>23464.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4193</th>\n",
" <td>84056041</td>\n",
" <td>US</td>\n",
" <td>USA</td>\n",
" <td>840.0</td>\n",
" <td>56041.0</td>\n",
" <td>Uinta</td>\n",
" <td>Wyoming</td>\n",
" <td>US</td>\n",
" <td>41.287818</td>\n",
" <td>-110.547578</td>\n",
" <td>Uinta, Wyoming, US</td>\n",
" <td>20226.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4194</th>\n",
" <td>84056043</td>\n",
" <td>US</td>\n",
" <td>USA</td>\n",
" <td>840.0</td>\n",
" <td>56043.0</td>\n",
" <td>Washakie</td>\n",
" <td>Wyoming</td>\n",
" <td>US</td>\n",
" <td>43.904516</td>\n",
" <td>-107.680187</td>\n",
" <td>Washakie, Wyoming, US</td>\n",
" <td>7805.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4195</th>\n",
" <td>84056045</td>\n",
" <td>US</td>\n",
" <td>USA</td>\n",
" <td>840.0</td>\n",
" <td>56045.0</td>\n",
" <td>Weston</td>\n",
" <td>Wyoming</td>\n",
" <td>US</td>\n",
" <td>43.839612</td>\n",
" <td>-104.567488</td>\n",
" <td>Weston, Wyoming, US</td>\n",
" <td>6927.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>4196 rows × 12 columns</p>\n",
"</div>"
3 years ago
],
"text/plain": [
" UID iso2 iso3 code3 FIPS Admin2 Province_State \\\n",
"0 4 AF AFG 4.0 NaN NaN NaN \n",
"1 8 AL ALB 8.0 NaN NaN NaN \n",
"2 12 DZ DZA 12.0 NaN NaN NaN \n",
"3 20 AD AND 20.0 NaN NaN NaN \n",
"4 24 AO AGO 24.0 NaN NaN NaN \n",
"... ... ... ... ... ... ... ... \n",
"4191 84056037 US USA 840.0 56037.0 Sweetwater Wyoming \n",
"4192 84056039 US USA 840.0 56039.0 Teton Wyoming \n",
"4193 84056041 US USA 840.0 56041.0 Uinta Wyoming \n",
"4194 84056043 US USA 840.0 56043.0 Washakie Wyoming \n",
"4195 84056045 US USA 840.0 56045.0 Weston Wyoming \n",
"\n",
" Country_Region Lat Long_ Combined_Key \\\n",
"0 Afghanistan 33.939110 67.709953 Afghanistan \n",
"1 Albania 41.153300 20.168300 Albania \n",
"2 Algeria 28.033900 1.659600 Algeria \n",
"3 Andorra 42.506300 1.521800 Andorra \n",
"4 Angola -11.202700 17.873900 Angola \n",
"... ... ... ... ... \n",
"4191 US 41.659439 -108.882788 Sweetwater, Wyoming, US \n",
"4192 US 43.935225 -110.589080 Teton, Wyoming, US \n",
"4193 US 41.287818 -110.547578 Uinta, Wyoming, US \n",
"4194 US 43.904516 -107.680187 Washakie, Wyoming, US \n",
"4195 US 43.839612 -104.567488 Weston, Wyoming, US \n",
"\n",
" Population \n",
"0 38928341.0 \n",
"1 2877800.0 \n",
"2 43851043.0 \n",
"3 77265.0 \n",
"4 32866268.0 \n",
"... ... \n",
"4191 42343.0 \n",
"4192 23464.0 \n",
"4193 20226.0 \n",
"4194 7805.0 \n",
"4195 6927.0 \n",
"\n",
"[4196 rows x 12 columns]"
]
},
3 years ago
"execution_count": 138,
"metadata": {},
3 years ago
"output_type": "execute_result"
}
],
3 years ago
"source": [
"countries = pd.read_csv(countries_dataset_url)\n",
"countries"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"Because this dataset contains information on both countries and provinces, to get the population of the whole country we need to be a little bit clever: "
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 139,
3 years ago
"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>UID</th>\n",
" <th>iso2</th>\n",
" <th>iso3</th>\n",
" <th>code3</th>\n",
" <th>FIPS</th>\n",
" <th>Admin2</th>\n",
" <th>Province_State</th>\n",
" <th>Country_Region</th>\n",
" <th>Lat</th>\n",
" <th>Long_</th>\n",
" <th>Combined_Key</th>\n",
" <th>Population</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>790</th>\n",
" <td>840</td>\n",
" <td>US</td>\n",
" <td>USA</td>\n",
" <td>840.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>US</td>\n",
" <td>40.0</td>\n",
" <td>-100.0</td>\n",
" <td>US</td>\n",
" <td>329466283.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
3 years ago
],
"text/plain": [
" UID iso2 iso3 code3 FIPS Admin2 Province_State Country_Region Lat \\\n",
"790 840 US USA 840.0 NaN NaN NaN US 40.0 \n",
"\n",
" Long_ Combined_Key Population \n",
"790 -100.0 US 329466283.0 "
]
},
3 years ago
"execution_count": 139,
"metadata": {},
3 years ago
"output_type": "execute_result"
}
],
3 years ago
"source": [
"countries[(countries['Country_Region']=='US') & countries['Province_State'].isna()]"
]
},
{
"cell_type": "code",
"execution_count": 140,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzYAAAEiCAYAAAArl0flAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA68ElEQVR4nO3deXxU9b3/8fdkmclkmcm+kYUtEAiriAKiSBWqVSted6WCenut4oK0t8rPeituVG2t9bqVuraKS2/FWm1VXACpoOyyhz2B7NtM1klm5vz+CEQiYQlMMjPJ6/l45DGZc75zzmdmHId3vssxGYZhCAAAAACCWIi/CwAAAACAU0WwAQAAABD0CDYAAAAAgh7BBgAAAEDQI9gAAAAACHoEGwAAAABBj2ADAAAAIOiF+buA7/N6vSoqKlJMTIxMJpO/ywEAAADgJ4ZhqLa2Vunp6QoJOXafTMAFm6KiImVmZvq7DAAAAAABorCwUBkZGcdsE3DBJiYmRlJr8Tabzc/VAAAAAPAXp9OpzMzMtoxwLAEXbA4NP7PZbAQbAAAAACc0RaXTiwcsW7ZMl1xyidLT02UymfT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tWlwaoySYvhDNfzLp8GmX79+Sk1N1eLFizV69GhJUnNzs5YuXarHHnvMl6cCAADASaptatHqvdVaubtSK3ZXakuRU+4OJsKEhpiUkxyt4X3sGp5h17A+dg1Jtclq5loqCDydDjZ1dXXauXNn2/09e/Zo/fr1io+PV1ZWlmbPnq1HH31UOTk5ysnJ0aOPPqrIyEhdd911Pi0cAAA
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"208.595938pt\" version=\"1.1\" viewBox=\"0 0 592.125 208.595938\" width=\"592.125pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:17:00.226979</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 208.595938 \r\nL 592.125 208.595938 \r\nL 592.125 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 26.925 173.52 \r\nL 584.925 173.52 \r\nL 584.925 7.2 \r\nL 26.925 7.2 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"m2b73fb3f6b\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"26.925\" xlink:href=\"#m2b73fb3f6b\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"93.694231\" xlink:href=\"#m2b73fb3f6b\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- Apr -->\r\n <g transform=\"translate(85.044231 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 2188 4044 \r\nL 1331 1722 \r\nL 3047 1722 \r\nL 2188 4044 \r\nz\r\nM 1831 4666 \r\nL 2547 4666 \r\nL 4325 0 \r\nL 3669 0 \r\nL 3244 1197 \r\nL 1141 1197 \r\nL 716 0 \r\nL 50 0 \r\nL 1831 4666 \r\nz\r\n\" id=\"DejaVuSans-41\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 1159 525 \r\nL 1159 -1331 \r\nL 581 -1331 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2969 \r\nQ 1341 3281 1617 3432 \r\nQ 1894 3584 2278 3584 \r\nQ 2916 3584 3314 3078 \r\nQ 3713 2572 3713 1747 \r\nQ 3713 922 3314 415 \r\nQ 2916 -91 2278 -91 \r\nQ 1894 -91 1617 61 \r\nQ 1341 213 1159 525 \r\nz\r\nM 3116 1747 \r\nQ 3116 2381 2855 2742 \r\nQ 2594 3103 2138 3103 \r\nQ 1681 3103 1420 2742 \r\nQ 1159 2381 1159 1747 \r\nQ 1159 1113 1420 752 \r\nQ 1681 391 2138 391 \r\nQ 2594 391 2855 752 \r\nQ 3116 1113 3116 1747 \r\nz\r\n\" id=\"DejaVuSans-70\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 2631 2963 \r\nQ 2534 3019 2420 3045 \r\nQ 2306 3072 2169 3072 \r\nQ 1681 3072 1420 2755 \r\nQ 1159 2438 1159 1844 \r\nL 1159 0 \r\nL 581 0 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2956 \r\nQ 1341 3275 1631 3429 \r\nQ 1922 3584 2338 3584 \r\nQ 2397 3584 2469 3576 \r\nQ 2541 3569 2628 3553 \r\nL 2631 2963 \r\nz\r\n\" id=\"DejaVuSans-72\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-41\"/>\r\n <use x=\"68.408203\" xlink:href=\"#DejaVuSans-70\"/>\r\n <use x=\"131.884766\" xlink:href=\"#DejaVuSans-72\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_3\">\r\n <g id=\"line2d_3\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"180.494231\" xlink:href=\"#m2b73fb3f6b\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_2\">\r\n <!-- Jul -->\r\n <g transform=\"translate(174.461418 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 4666 \r\nL 1259 4666 \r\nL 1259 325 \r\nQ 12
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"pop = countries[(countries['Country_Region']=='US') & countries['Province_State'].isna()]['Population'].iloc[0]\n",
"df['pinfected'] = df['infected']*100 / pop\n",
"df['pinfected'].plot(figsize=(10,3))\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
3 years ago
"\n",
"## Computing $R_t$\n",
"\n",
"To see how infectious is the disease, we look at the **basic reproduction number** $R_0$, which indicated the number of people that an infected person would further infect. When $R_0$ is more than 1, the epidemic is likely to spread.\n",
"\n",
"$R_0$ is a property of the disease itself, and does not take into account some protective measures that people may take to slow down the pandemic. During the pandemic progression, we can estimate the reproduction number $R_t$ at any given time $t$. It has been shown that this number can be roughly estimated by taking a window of 8 days, and computing $$R_t=\\frac{I_{t-7}+I_{t-6}+I_{t-5}+I_{t-4}}{I_{t-3}+I_{t-2}+I_{t-1}+I_t}$$\n",
"where $I_t$ is the number of newly infected individuals on day $t$.\n",
"\n",
"Let's compute $R_t$ for our pandemic data. To do this, we will take a rolling window of 8 `ninfected` values, and apply the function to compute the ratio above:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 141,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzYAAAEiCAYAAAArl0flAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABGg0lEQVR4nO3deXxU9b3/8fdMlkkm+76QEAKEfXFBEUQBBdyrYqsVtVptq4JW6vXSWnt/ovcKrW292Eu1al2wda9rXRBcCCoiAWTfIUAC2bfJOpOZOb8/QgaGCWggM8mE1/PxmMcjOedk8pk5s5z3+S7HZBiGIQAAAAAIYubuLgAAAAAAThbBBgAAAEDQI9gAAAAACHoEGwAAAABBj2ADAAAAIOgRbAAAAAAEPYINAAAAgKAX2t0FHM3tduvgwYOKiYmRyWTq7nIAAAAAdBPDMFRfX6/MzEyZzcdvk+lxwebgwYPKzs7u7jIAAAAA9BBFRUXKyso67jY9LtjExMRIais+Nja2m6sBAAAA0F1sNpuys7M9GeF4elywae9+FhsbS7ABAAAA8L2GqDB5AAAAAICgR7ABAAAAEPQINgAAAACCHsEGAAAAQNAj2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ZXXHGFLr30Ug0aNEiDBg3SI488oujoaK1cuVKGYWjBggV64IEHNH36dI0YMUKLFi1SU1OTXn75ZX/VH1QYYwMAAAD4xwmPsXG5XHr11VfV2NiocePGqbCwUKWlpZo2bZpnG4vFookTJ2rFihXHvB+73S6bzeZ1663aW2y4jg0AAADQtTodbDZu3Kjo6GhZLBbdcccdevvttzV
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"208.595938pt\" version=\"1.1\" viewBox=\"0 0 592.125 208.595938\" width=\"592.125pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:17:00.882137</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 208.595938 \r\nL 592.125 208.595938 \r\nL 592.125 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 26.925 173.52 \r\nL 584.925 173.52 \r\nL 584.925 7.2 \r\nL 26.925 7.2 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"m3866f6add5\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"26.925\" xlink:href=\"#m3866f6add5\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"93.694231\" xlink:href=\"#m3866f6add5\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- Apr -->\r\n <g transform=\"translate(85.044231 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 2188 4044 \r\nL 1331 1722 \r\nL 3047 1722 \r\nL 2188 4044 \r\nz\r\nM 1831 4666 \r\nL 2547 4666 \r\nL 4325 0 \r\nL 3669 0 \r\nL 3244 1197 \r\nL 1141 1197 \r\nL 716 0 \r\nL 50 0 \r\nL 1831 4666 \r\nz\r\n\" id=\"DejaVuSans-41\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 1159 525 \r\nL 1159 -1331 \r\nL 581 -1331 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2969 \r\nQ 1341 3281 1617 3432 \r\nQ 1894 3584 2278 3584 \r\nQ 2916 3584 3314 3078 \r\nQ 3713 2572 3713 1747 \r\nQ 3713 922 3314 415 \r\nQ 2916 -91 2278 -91 \r\nQ 1894 -91 1617 61 \r\nQ 1341 213 1159 525 \r\nz\r\nM 3116 1747 \r\nQ 3116 2381 2855 2742 \r\nQ 2594 3103 2138 3103 \r\nQ 1681 3103 1420 2742 \r\nQ 1159 2381 1159 1747 \r\nQ 1159 1113 1420 752 \r\nQ 1681 391 2138 391 \r\nQ 2594 391 2855 752 \r\nQ 3116 1113 3116 1747 \r\nz\r\n\" id=\"DejaVuSans-70\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 2631 2963 \r\nQ 2534 3019 2420 3045 \r\nQ 2306 3072 2169 3072 \r\nQ 1681 3072 1420 2755 \r\nQ 1159 2438 1159 1844 \r\nL 1159 0 \r\nL 581 0 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2956 \r\nQ 1341 3275 1631 3429 \r\nQ 1922 3584 2338 3584 \r\nQ 2397 3584 2469 3576 \r\nQ 2541 3569 2628 3553 \r\nL 2631 2963 \r\nz\r\n\" id=\"DejaVuSans-72\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-41\"/>\r\n <use x=\"68.408203\" xlink:href=\"#DejaVuSans-70\"/>\r\n <use x=\"131.884766\" xlink:href=\"#DejaVuSans-72\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_3\">\r\n <g id=\"line2d_3\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"180.494231\" xlink:href=\"#m3866f6add5\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_2\">\r\n <!-- Jul -->\r\n <g transform=\"translate(174.461418 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 4666 \r\nL 1259 4666 \r\nL 1259 325 \r\nQ 12
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"df['Rt'] = df['ninfected'].rolling(8).apply(lambda x: x[4:].sum()/x[:4].sum())\n",
"df['Rt'].plot()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
3 years ago
"You can see that there are some gaps in the graph. Those can be caused by either `NaN`, if `inf` values being present in the dataset. `inf` may be caused by division by 0, and `NaN` can indicate missing data, or no data available to compute the result (like in the very beginning of our frame, where rolling window of width 8 is not yet available). To make the graph nicer, we need to fill those values using `replace` and `fillna` function.\n",
"\n",
"Let's further look at the beginning of the pandemic. We will also limit the y-axis values to show only values below 6, in order to see better, and draw horizontal line at 1."
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 142,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAy0AAAEoCAYAAABVQh6cAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABh5UlEQVR4nO3dd3hb5fk38K+2bNmW9x5xEmc6DmQSCBAKBMIupIMmlNmyR2l7AV2UrkAHpb9SIKywCfACLQ1NaFKSQAiZkMTZy4njvWVbtjXP+4d0juR4StY4Ov5+rssX2H4kP3Js+dy6x6MSBEEAERERERGRTKmjvQEiIiIiIqLBMGghIiIiIiJZY9BCRERERESyxqCFiIiIiIhkjUELERERERHJGoMWIiIiIiKSNQYtREREREQkawxaiIiIiIhI1hi0EBERERGRrDFoISIiIiIiWQs4aKmursbSpUuRlpaG+Ph4nHHGGdi5c2c49kZERERERARtIItbW1txzjnn4IILLsDq1auRmZmJY8eOITk5OUzbIyIiIiKi0U4lCIIw3MUPP/wwvvjiC3z++efh3BMREREREZEkoKBlypQpuOSSS1BVVYWNGzciLy8Pd911F37wgx8MeBubzQabzSa973a70dLSgrS0NKhUqpHtnoiIiIiIYpYgCOjo6EBubi7U6kE6V4QAGAwGwWAwCI888ojw1VdfCc8995xgNBqFV199dcDbPProowIAvvGNb3zjG9/4xje+8Y1vfOv37dSpU4PGIQFlWvR6PWbNmoXNmzdLH7vvvvuwfft2fPnll/3e5vRMi8ViQWFhIU6dOoWkpKThfmkiIlkQBAHTfv1fAMBnP12A1ARDlHcEzP79WnTb3fjP/f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WjVcbgEffl2NhU99hjvf2CkdAEpEREMLOGg5cuQIcnNzUVxcjO9+97s4fvz4oOttNhva29t7vVFkvbW1Ej9+bzeWf3Ys2lshinmCdE6LvKIWMdNysM7zHDspJxFG3fAz4WMzEgAAdZae0G9uFGvq9AQtl07Nxkf3nIOFU7IgCMDqvXW44u+bcNOKbdh5siXKuyQikr+Agpa5c+fitddewyeffIIXXngBdXV1OPvss9HcPPArc8uWLYPZbJbeCgoKRrxpCkx9u+cipK6dFyNEIyXXPvU4nafaV8wEDXU+y+nSEvQAgGarPZTbGvUavUFLeoIBZfnJeP77s/DJA+fh6jNyoVYBGw414rpnv8TTnx6J8k6JiOQtoKBl0aJFuO666zBt2jRcdNFF+PjjjwEAr7766oC3eeSRR2CxWKS3U6dOjWzHFLAuh+ewOavNGeWdEMU+QRBHHkd5I6cRMy2i6cPsZxGlJxgAAC1WOyeIhVBThycITE/USx+bmJ2Iv333THz64wVYPDMfAPD0+qNo9gY4RETU14hGHptMJkybNg1Hjgz8CpHBYEBSUlKvN4qsLm+wYrW5orwTotgnXs7LtTxMFGimJdXkuah2uQW0dbP/LVTETEuGNyj0NybdhD8tLkNZvhk9Djde3FQR6e0REcWMEQUtNpsNBw4cQE5OTqj2Q2FgtXuClU5mWohGTK6Zlji/oMWoU6MkMyGg2+s0aiTH6wD4+jBo5Jq8jfjpiX2DFsBzSOm93ygBALy2+QTaulieR0TUn4CClp/85CfYuHEjKioqsHXrVixevBjt7e248cYbw7U/CoFuO8vDiEJFviOPfRPsS3PN0GoCf00qzZttYdASOk2DZFpEF03OxKTsRFjtLqz44kSEdkZEFFsC+qtWVVWF66+/HhMnTsS1114LvV6PLVu2oKioKFz7oxCw2sXyMAYtRCMltnvIK2TpXR4WaGmYSOxrae7kq/2h4HYL0mCD9EGCFv9sy4ovKtD
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"212.395156pt\" version=\"1.1\" viewBox=\"0 0 585.7625 212.395156\" width=\"585.7625pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:17:01.320930</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 212.395156 \r\nL 585.7625 212.395156 \r\nL 585.7625 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 20.5625 177.319219 \r\nL 578.5625 177.319219 \r\nL 578.5625 10.999219 \r\nL 20.5625 10.999219 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"mc748ae0a92\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"20.5625\" xlink:href=\"#mc748ae0a92\" y=\"177.319219\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"76.926136\" xlink:href=\"#mc748ae0a92\" y=\"177.319219\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- Feb -->\r\n <g transform=\"translate(68.074574 191.917656)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 4666 \r\nL 3309 4666 \r\nL 3309 4134 \r\nL 1259 4134 \r\nL 1259 2759 \r\nL 3109 2759 \r\nL 3109 2228 \r\nL 1259 2228 \r\nL 1259 0 \r\nL 628 0 \r\nL 628 4666 \r\nz\r\n\" id=\"DejaVuSans-46\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 3597 1894 \r\nL 3597 1613 \r\nL 953 1613 \r\nQ 991 1019 1311 708 \r\nQ 1631 397 2203 397 \r\nQ 2534 397 2845 478 \r\nQ 3156 559 3463 722 \r\nL 3463 178 \r\nQ 3153 47 2828 -22 \r\nQ 2503 -91 2169 -91 \r\nQ 1331 -91 842 396 \r\nQ 353 884 353 1716 \r\nQ 353 2575 817 3079 \r\nQ 1281 3584 2069 3584 \r\nQ 2775 3584 3186 3129 \r\nQ 3597 2675 3597 1894 \r\nz\r\nM 3022 2063 \r\nQ 3016 2534 2758 2815 \r\nQ 2500 3097 2075 3097 \r\nQ 1594 3097 1305 2825 \r\nQ 1016 2553 972 2059 \r\nL 3022 2063 \r\nz\r\n\" id=\"DejaVuSans-65\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 3116 1747 \r\nQ 3116 2381 2855 2742 \r\nQ 2594 3103 2138 3103 \r\nQ 1681 3103 1420 2742 \r\nQ 1159 2381 1159 1747 \r\nQ 1159 1113 1420 752 \r\nQ 1681 391 2138 391 \r\nQ 2594 391 2855 752 \r\nQ 3116 1113 3116 1747 \r\nz\r\nM 1159 2969 \r\nQ 1341 3281 1617 3432 \r\nQ 1894 3584 2278 3584 \r\nQ 2916 3584 3314 3078 \r\nQ 3713 2572 3713 1747 \r\nQ 3713 922 3314 415 \r\nQ 2916 -91 2278 -91 \r\nQ 1894 -91 1617 61 \r\nQ 1341 213 1159 525 \r\nL 1159 0 \r\nL 581 0 \r\nL 581 4863 \r\nL 1159 4863 \r\nL 1159 2969 \r\nz\r\n\" id=\"DejaVuSans-62\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-46\"/>\r\n <use x=\"52.019531\" xlink:href=\"#DejaVuSans-65\"/>\r\n <use x=\"113.542969\" xlink:href=\"#DejaVuSans-62\"/>\r\n </g>\r\n <!-- 2020 -->\r\n <g transform=\"translate(64.201136 203.115469)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 1228 531 \r\nL 3431 531 \r\nL 3431 0 \r\nL 469 0 \r\nL 469 531 \r\nQ 828 903 1448 1529 \r\nQ 2069 2156 2228 2338 \r\nQ 2531 2678 26
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"ax = df[df.index<\"2020-05-01\"]['Rt'].replace(np.inf,np.nan).fillna(method='pad').plot(figsize=(10,3))\n",
"ax.set_ylim([0,6])\n",
"ax.axhline(1,linestyle='--',color='red')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"Another interesting indicator of the pandemic is the **derivative**, or **daily difference** in new cases. It allows us to see clearly when pandemic is increasing or declining. "
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 143,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2UAAAEiCAYAAAB5tHquAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hA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QEp9ryoiIiKhROxezyUREZ8poMMAhi8Q015QZVfuUydeIqcaLY+Sxl7/GIH6PLfChRERERGfO34wzEdH5ZjYZ6sxkeVvi+2bB1OM1G30wU0ZERESNmeLkhpkyIroA5J81JqNRUb7o0MqUSeWLnn3KAmqJr32b3KeMiIiIGp26WlETEZ1rdpe3XNFsNNQ5OSQFZVqZMnVLfJfy/4D/bo3+MCgjIiKiC0Je4sPyRSK6EOxOeabMEEBLfPf/NfcpU7fEFzs06qyX5ZoyIiIiuqBySqpxzb9+w4ItGbpjmCkjogvN7vBGVSajAU5ZWktrcsjoZ58y9RoxMd7TK1/kmjIiIiK6oDanF2Bfdim+SzulO4ZBGRFdaHZZqssAVdCkWb7oLjvUbvShHCv+viB4SxXl98c1ZURERHRBaZ3A6I0BlGswiIjOl1pZkOQSvPuPAfqZMkWJYwAt8cXbBpS3zzVlREREdEGJAZdWNzP1GIBryojowpCvKXO6hDoz9gaDfjMQn5b4GrdlVwWBgWJQRkRERGdNPFnx1+pebzE8EdH5oiwnFDQbfSjb5kO3GYhPS3yN9WZcU0ZEREQNxhFApuxMN1UlItKzbG8O9mWV6l5f61B
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"208.595938pt\" version=\"1.1\" viewBox=\"0 0 625.954688 208.595938\" width=\"625.954688pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:17:01.769624</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M -0 208.595938 \r\nL 625.954688 208.595938 \r\nL 625.954688 0 \r\nL -0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 60.754688 173.52 \r\nL 618.754688 173.52 \r\nL 618.754688 7.2 \r\nL 60.754688 7.2 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"m6e594c14d7\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"60.754688\" xlink:href=\"#m6e594c14d7\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"127.523918\" xlink:href=\"#m6e594c14d7\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- Apr -->\r\n <g transform=\"translate(118.873918 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 2188 4044 \r\nL 1331 1722 \r\nL 3047 1722 \r\nL 2188 4044 \r\nz\r\nM 1831 4666 \r\nL 2547 4666 \r\nL 4325 0 \r\nL 3669 0 \r\nL 3244 1197 \r\nL 1141 1197 \r\nL 716 0 \r\nL 50 0 \r\nL 1831 4666 \r\nz\r\n\" id=\"DejaVuSans-41\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 1159 525 \r\nL 1159 -1331 \r\nL 581 -1331 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2969 \r\nQ 1341 3281 1617 3432 \r\nQ 1894 3584 2278 3584 \r\nQ 2916 3584 3314 3078 \r\nQ 3713 2572 3713 1747 \r\nQ 3713 922 3314 415 \r\nQ 2916 -91 2278 -91 \r\nQ 1894 -91 1617 61 \r\nQ 1341 213 1159 525 \r\nz\r\nM 3116 1747 \r\nQ 3116 2381 2855 2742 \r\nQ 2594 3103 2138 3103 \r\nQ 1681 3103 1420 2742 \r\nQ 1159 2381 1159 1747 \r\nQ 1159 1113 1420 752 \r\nQ 1681 391 2138 391 \r\nQ 2594 391 2855 752 \r\nQ 3116 1113 3116 1747 \r\nz\r\n\" id=\"DejaVuSans-70\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 2631 2963 \r\nQ 2534 3019 2420 3045 \r\nQ 2306 3072 2169 3072 \r\nQ 1681 3072 1420 2755 \r\nQ 1159 2438 1159 1844 \r\nL 1159 0 \r\nL 581 0 \r\nL 581 3500 \r\nL 1159 3500 \r\nL 1159 2956 \r\nQ 1341 3275 1631 3429 \r\nQ 1922 3584 2338 3584 \r\nQ 2397 3584 2469 3576 \r\nQ 2541 3569 2628 3553 \r\nL 2631 2963 \r\nz\r\n\" id=\"DejaVuSans-72\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-41\"/>\r\n <use x=\"68.408203\" xlink:href=\"#DejaVuSans-70\"/>\r\n <use x=\"131.884766\" xlink:href=\"#DejaVuSans-72\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_3\">\r\n <g id=\"line2d_3\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"214.323918\" xlink:href=\"#m6e594c14d7\" y=\"173.52\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_2\">\r\n <!-- Jul -->\r\n <g transform=\"translate(208.291106 188.118438)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 4666 \r\nL 12
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"df['ninfected'].diff().plot()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
"Given the fact that there are a lot of fluctuations in data caused by reporting, it makes sense to smooth the curve by running rolling average to get the overall picture. Let's again focus on the first months of the pandemic:"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": 150,
3 years ago
"metadata": {},
"outputs": [
{
"data": {
3 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1MAAAEjCAYAAADXBVt0AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABsx0lEQVR4nO3dd3hb5dkG8PtIsiRPedux45XEcSbZJM4gCSMkhbJK4SMkhbIJkKaBAm2/llWSj0KBlhlmKCtAy4YGUghhJM52dpzllXgveWue74+jcyzZki3ZluVx/67LF+To6OiVdHysR8/zPq8giqIIIiIiIiIi8okq0AMgIiIiIiIaiBhMERERERERdQODKSIiIiIiom5gMEVERERERNQNDKaIiIiIiIi6gcEUERERERFRNzCYIiIiIiIi6gYGU0RERERERN2gCfQA+gu73Y6SkhKEh4dDEIRAD4eIiIiIiAJEFEU0NDQgKSkJKpXn/BODKYeSkhKkpKQEehhERERERNRPFBcXY/jw4R5v92sw9cILL+CFF15AQUEBAGD8+PH485//jCVLlgCQIr6HHnoIL730EmprazFz5kw899xzGD9+vHIMk8mEe+65B++++y5aWlpw3nnn4fnnn3d5UrW1tVi5ciU+/fRTAMAll1yCZ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5GDmzJkAgJycHGRnZ+Po0aPIysrqcmz19fUwGAwwGo2IiIjw34tARERDzlXrtmFHfg2evnoyLpuS7PX9Wi023PnOHvz3SAU0KgF/u2oSLp3s/f2
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<svg height=\"209.090847pt\" version=\"1.1\" viewBox=\"0 0 613.229687 209.090847\" width=\"613.229687pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-08-30T11:19:23.000659</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 209.090847 \r\nL 613.229687 209.090847 \r\nL 613.229687 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 48.029687 174.01491 \r\nL 606.029688 174.01491 \r\nL 606.029688 7.69491 \r\nL 48.029687 7.69491 \r\nz\r\n\" style=\"fill:#ffffff;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\">\r\n <g id=\"xtick_1\">\r\n <g id=\"line2d_1\">\r\n <defs>\r\n <path d=\"M 0 0 \r\nL 0 3.5 \r\n\" id=\"m8e3b50f4fc\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n </defs>\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"48.029688\" xlink:href=\"#m8e3b50f4fc\" y=\"174.01491\"/>\r\n </g>\r\n </g>\r\n </g>\r\n <g id=\"xtick_2\">\r\n <g id=\"line2d_2\">\r\n <g>\r\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"90.952764\" xlink:href=\"#m8e3b50f4fc\" y=\"174.01491\"/>\r\n </g>\r\n </g>\r\n <g id=\"text_1\">\r\n <!-- Feb -->\r\n <g transform=\"translate(82.101202 188.613347)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 628 4666 \r\nL 3309 4666 \r\nL 3309 4134 \r\nL 1259 4134 \r\nL 1259 2759 \r\nL 3109 2759 \r\nL 3109 2228 \r\nL 1259 2228 \r\nL 1259 0 \r\nL 628 0 \r\nL 628 4666 \r\nz\r\n\" id=\"DejaVuSans-46\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 3597 1894 \r\nL 3597 1613 \r\nL 953 1613 \r\nQ 991 1019 1311 708 \r\nQ 1631 397 2203 397 \r\nQ 2534 397 2845 478 \r\nQ 3156 559 3463 722 \r\nL 3463 178 \r\nQ 3153 47 2828 -22 \r\nQ 2503 -91 2169 -91 \r\nQ 1331 -91 842 396 \r\nQ 353 884 353 1716 \r\nQ 353 2575 817 3079 \r\nQ 1281 3584 2069 3584 \r\nQ 2775 3584 3186 3129 \r\nQ 3597 2675 3597 1894 \r\nz\r\nM 3022 2063 \r\nQ 3016 2534 2758 2815 \r\nQ 2500 3097 2075 3097 \r\nQ 1594 3097 1305 2825 \r\nQ 1016 2553 972 2059 \r\nL 3022 2063 \r\nz\r\n\" id=\"DejaVuSans-65\" transform=\"scale(0.015625)\"/>\r\n <path d=\"M 3116 1747 \r\nQ 3116 2381 2855 2742 \r\nQ 2594 3103 2138 3103 \r\nQ 1681 3103 1420 2742 \r\nQ 1159 2381 1159 1747 \r\nQ 1159 1113 1420 752 \r\nQ 1681 391 2138 391 \r\nQ 2594 391 2855 752 \r\nQ 3116 1113 3116 1747 \r\nz\r\nM 1159 2969 \r\nQ 1341 3281 1617 3432 \r\nQ 1894 3584 2278 3584 \r\nQ 2916 3584 3314 3078 \r\nQ 3713 2572 3713 1747 \r\nQ 3713 922 3314 415 \r\nQ 2916 -91 2278 -91 \r\nQ 1894 -91 1617 61 \r\nQ 1341 213 1159 525 \r\nL 1159 0 \r\nL 581 0 \r\nL 581 4863 \r\nL 1159 4863 \r\nL 1159 2969 \r\nz\r\n\" id=\"DejaVuSans-62\" transform=\"scale(0.015625)\"/>\r\n </defs>\r\n <use xlink:href=\"#DejaVuSans-46\"/>\r\n <use x=\"52.019531\" xlink:href=\"#DejaVuSans-65\"/>\r\n <use x=\"113.542969\" xlink:href=\"#DejaVuSans-62\"/>\r\n </g>\r\n <!-- 2020 -->\r\n <g transform=\"translate(78.227764 199.81116)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 1228 531 \r\nL 3431 531 \r\nL 3431 0 \r\nL 469 0 \r\nL 469 531 \r\nQ 828 903 1448 1529 \r\nQ 2069 2156 2228 2338 \r\nQ 253
"text/plain": [
"<Figure size 1000x300 with 1 Axes>"
3 years ago
]
},
3 years ago
"metadata": {},
"output_type": "display_data"
}
],
3 years ago
"source": [
"ax=df[df.index<\"2020-06-01\"]['ninfected'].diff().rolling(7).mean().plot()\n",
"ax.axhline(0,linestyle='-.',color='red')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
3 years ago
"\n",
"## Challenge\n",
"\n",
"Now it is time for you to play more with the code and data! Here are a few suggestions you can experiment with:\n",
"* See the spread of the pandemic in different countries.\n",
"* Plot $R_t$ graphs for several countries on one plot for comparison, or make several plots side-by-side\n",
"* See how the number of deaths and recoveries correlate with number of infected cases.\n",
"* Try to find out how long a typical disease lasts by visually correlating infection rate and deaths rate and looking for some anomalies. You may need to look at different countries to find that out.\n",
"* Calculate the fatality rate and how it changes over time. You may want to take into account the length of the disease in days to shift one time series before doing calculations"
3 years ago
]
},
{
"cell_type": "markdown",
3 years ago
"metadata": {},
"source": [
3 years ago
"## References\n",
"\n",
"You may look at further studies of COVID epidemic spread in the following publications:\n",
"* [Sliding SIR Model for Rt Estimation during COVID Pandemic](https://soshnikov.com/science/sliding-sir-model-for-rt-estimation/), blog post by [Dmitry Soshnikov](http://soshnikov.com)\n",
"* T.Petrova, D.Soshnikov, A.Grunin. [Estimation of Time-Dependent Reproduction Number for Global COVID-19 Outbreak](https://www.preprints.org/manuscript/202006.0289/v1). *Preprints* **2020**, 2020060289 (doi: 10.20944/preprints202006.0289.v1)\n",
"* [Code for the above paper on GitHub](https://github.com/shwars/SlidingSIR)"
3 years ago
]
},
{
"cell_type": "code",
"execution_count": null,
3 years ago
"metadata": {},
"outputs": [],
3 years ago
"source": []
}
],
"metadata": {
3 years ago
"interpreter": {
"hash": "86193a1ab0ba47eac1c69c1756090baa3b420b3eea7d4aafab8b85f8b312f0c5"
},
"kernelspec": {
"display_name": "Python 3.8.8 64-bit (conda)",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
3 years ago
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
3 years ago
"pygments_lexer": "ipython3",
"version": "3.8.8"
},
3 years ago
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}