Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
covid-19-public-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christine Choirat
covid-19-public-data
Commits
c42bb0d6
Commit
c42bb0d6
authored
5 years ago
by
Chandrasekhar Ramakrishnan
Browse files
Options
Downloads
Patches
Plain Diff
feat: example for working with covidtracking data
parent
830a5e25
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/examples/covidtracking-example.ipynb
+1058
-0
1058 additions, 0 deletions
notebooks/examples/covidtracking-example.ipynb
with
1058 additions
and
0 deletions
notebooks/examples/covidtracking-example.ipynb
0 → 100644
+
1058
−
0
View file @
c42bb0d6
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import altair as alt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Look at the metadata"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"metadata_df = pd.read_json('../../data/covidtracking/states-metadata.json')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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>state</th>\n",
" <th>dataSite</th>\n",
" <th>covid19Site</th>\n",
" <th>twitter</th>\n",
" <th>pui</th>\n",
" <th>pum</th>\n",
" <th>notes</th>\n",
" <th>name</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>AK</td>\n",
" <td>http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-...</td>\n",
" <td>http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-...</td>\n",
" <td>@Alaska_DHSS</td>\n",
" <td>All data</td>\n",
" <td>False</td>\n",
" <td>Unclear if their reported number means \"person...</td>\n",
" <td>Alaska</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>AL</td>\n",
" <td>http://www.alabamapublichealth.gov/infectiousd...</td>\n",
" <td>http://www.alabamapublichealth.gov/infectiousd...</td>\n",
" <td>@alpublichealth</td>\n",
" <td>No data</td>\n",
" <td>False</td>\n",
" <td>Last negative count from 3/16.</td>\n",
" <td>Alabama</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>AR</td>\n",
" <td>https://www.healthy.arkansas.gov/programs-serv...</td>\n",
" <td>https://www.healthy.arkansas.gov/programs-serv...</td>\n",
" <td>@adhpio</td>\n",
" <td>All data</td>\n",
" <td>True</td>\n",
" <td>Pending = \"PUIs\"</td>\n",
" <td>Arkansas</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>AZ</td>\n",
" <td>https://www.azdhs.gov/preparedness/epidemiolog...</td>\n",
" <td>https://www.azdhs.gov/preparedness/epidemiolog...</td>\n",
" <td>@azdhs</td>\n",
" <td>All data</td>\n",
" <td>False</td>\n",
" <td>Negative = “Ruled Out”. Our total is slightly ...</td>\n",
" <td>Arizona</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>CA</td>\n",
" <td>https://www.cdph.ca.gov/Programs/CID/DCDC/Page...</td>\n",
" <td>https://www.cdph.ca.gov/Programs/CID/DCDC/Page...</td>\n",
" <td>@CAPublicHealth</td>\n",
" <td>Only positives</td>\n",
" <td>False</td>\n",
" <td>Only positives reported regularly. Add deaths ...</td>\n",
" <td>California</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" state dataSite \\\n",
"0 AK http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-... \n",
"1 AL http://www.alabamapublichealth.gov/infectiousd... \n",
"2 AR https://www.healthy.arkansas.gov/programs-serv... \n",
"3 AZ https://www.azdhs.gov/preparedness/epidemiolog... \n",
"4 CA https://www.cdph.ca.gov/Programs/CID/DCDC/Page... \n",
"\n",
" covid19Site twitter \\\n",
"0 http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-... @Alaska_DHSS \n",
"1 http://www.alabamapublichealth.gov/infectiousd... @alpublichealth \n",
"2 https://www.healthy.arkansas.gov/programs-serv... @adhpio \n",
"3 https://www.azdhs.gov/preparedness/epidemiolog... @azdhs \n",
"4 https://www.cdph.ca.gov/Programs/CID/DCDC/Page... @CAPublicHealth \n",
"\n",
" pui pum notes \\\n",
"0 All data False Unclear if their reported number means \"person... \n",
"1 No data False Last negative count from 3/16. \n",
"2 All data True Pending = \"PUIs\" \n",
"3 All data False Negative = “Ruled Out”. Our total is slightly ... \n",
"4 Only positives False Only positives reported regularly. Add deaths ... \n",
"\n",
" name \n",
"0 Alaska \n",
"1 Alabama \n",
"2 Arkansas \n",
"3 Arizona \n",
"4 California "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"metadata_df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Look at the data"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"data_df = pd.read_json('../../data/covidtracking/states-daily.json')\n",
"data_df['date'] = pd.to_datetime(data_df['date'], format=\"%Y%m%d\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"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>date</th>\n",
" <th>state</th>\n",
" <th>positive</th>\n",
" <th>negative</th>\n",
" <th>pending</th>\n",
" <th>death</th>\n",
" <th>total</th>\n",
" <th>dateChecked</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2020-03-18</td>\n",
" <td>AK</td>\n",
" <td>6.0</td>\n",
" <td>406.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>412.0</td>\n",
" <td>2020-03-18T20:00:00Z</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2020-03-18</td>\n",
" <td>AL</td>\n",
" <td>46.0</td>\n",
" <td>28.0</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>74.0</td>\n",
" <td>2020-03-18T20:00:00Z</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2020-03-18</td>\n",
" <td>AR</td>\n",
" <td>33.0</td>\n",
" <td>236.0</td>\n",
" <td>50.0</td>\n",
" <td>NaN</td>\n",
" <td>319.0</td>\n",
" <td>2020-03-18T20:00:00Z</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2020-03-18</td>\n",
" <td>AZ</td>\n",
" <td>28.0</td>\n",
" <td>148.0</td>\n",
" <td>102.0</td>\n",
" <td>0.0</td>\n",
" <td>278.0</td>\n",
" <td>2020-03-18T20:00:00Z</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2020-03-18</td>\n",
" <td>CA</td>\n",
" <td>611.0</td>\n",
" <td>7981.0</td>\n",
" <td>NaN</td>\n",
" <td>13.0</td>\n",
" <td>8592.0</td>\n",
" <td>2020-03-18T20:00:00Z</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" date state positive negative pending death total \\\n",
"0 2020-03-18 AK 6.0 406.0 NaN NaN 412.0 \n",
"1 2020-03-18 AL 46.0 28.0 NaN 0.0 74.0 \n",
"2 2020-03-18 AR 33.0 236.0 50.0 NaN 319.0 \n",
"3 2020-03-18 AZ 28.0 148.0 102.0 0.0 278.0 \n",
"4 2020-03-18 CA 611.0 7981.0 NaN 13.0 8592.0 \n",
"\n",
" dateChecked \n",
"0 2020-03-18T20:00:00Z \n",
"1 2020-03-18T20:00:00Z \n",
"2 2020-03-18T20:00:00Z \n",
"3 2020-03-18T20:00:00Z \n",
"4 2020-03-18T20:00:00Z "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data_df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How many data points per state?"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>state</th>\n",
" <th>date</th>\n",
" <th>positive</th>\n",
" <th>negative</th>\n",
" <th>pending</th>\n",
" <th>death</th>\n",
" <th>total</th>\n",
" <th>dateChecked</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>AZ</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>6</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>CA</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>0</td>\n",
" <td>7</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>FL</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>14</td>\n",
" <td>8</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>GA</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>6</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>IL</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>12</td>\n",
" <td>2</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>MA</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>6</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>14</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>NC</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>7</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>NH</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>0</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37</th>\n",
" <td>NY</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>13</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40</th>\n",
" <td>OR</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>1</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>44</th>\n",
" <td>SC</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>47</th>\n",
" <td>TX</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>52</th>\n",
" <td>WA</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>13</td>\n",
" <td>2</td>\n",
" <td>8</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>53</th>\n",
" <td>WI</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>15</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>CO</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>DC</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>12</td>\n",
" <td>0</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>MD</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>MI</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>12</td>\n",
" <td>0</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>NE</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>11</td>\n",
" <td>0</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>NJ</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>9</td>\n",
" <td>12</td>\n",
" <td>8</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <td>NV</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>38</th>\n",
" <td>OH</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>12</td>\n",
" <td>0</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>46</th>\n",
" <td>TN</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>8</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>49</th>\n",
" <td>VA</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>14</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" <td>13</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>AK</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>7</td>\n",
" <td>0</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>AR</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>0</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>DE</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>11</td>\n",
" <td>0</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>IA</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>8</td>\n",
" <td>0</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>IN</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>9</td>\n",
" <td>0</td>\n",
" <td>5</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>KS</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>KY</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>MN</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>NM</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41</th>\n",
" <td>PA</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>8</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>51</th>\n",
" <td>VT</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>54</th>\n",
" <td>WV</td>\n",
" <td>13</td>\n",
" <td>12</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" <td>4</td>\n",
" <td>13</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>AL</td>\n",
" <td>12</td>\n",
" <td>11</td>\n",
" <td>9</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>CT</td>\n",
" <td>12</td>\n",
" <td>11</td>\n",
" <td>11</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>HI</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>ID</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>LA</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>11</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>ME</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>6</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>MO</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>7</td>\n",
" <td>0</td>\n",
" <td>5</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>MS</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>8</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>MT</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>ND</td>\n",
" <td>12</td>\n",
" <td>11</td>\n",
" <td>12</td>\n",
" <td>8</td>\n",
" <td>6</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>39</th>\n",
" <td>OK</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>11</td>\n",
" <td>11</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>43</th>\n",
" <td>RI</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>11</td>\n",
" <td>11</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>45</th>\n",
" <td>SD</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>1</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>48</th>\n",
" <td>UT</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>7</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>55</th>\n",
" <td>WY</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>AS</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>GU</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>MP</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>42</th>\n",
" <td>PR</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50</th>\n",
" <td>VI</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" state date positive negative pending death total dateChecked\n",
"4 AZ 15 15 15 15 6 15 15\n",
"5 CA 15 15 15 0 7 15 15\n",
"10 FL 15 15 15 14 8 15 15\n",
"11 GA 15 15 1 0 6 15 15\n",
"16 IL 15 15 15 12 2 15 15\n",
"21 MA 15 15 6 0 0 14 15\n",
"30 NC 15 15 7 2 3 15 15\n",
"33 NH 15 15 15 15 0 15 15\n",
"37 NY 15 15 13 4 4 15 15\n",
"40 OR 15 15 15 15 1 15 15\n",
"44 SC 15 15 15 3 3 15 15\n",
"47 TX 15 15 2 0 2 15 15\n",
"52 WA 15 15 13 2 8 15 15\n",
"53 WI 15 15 15 5 0 15 15\n",
"6 CO 14 14 14 4 5 14 14\n",
"8 DC 14 14 14 12 0 14 14\n",
"22 MD 14 14 14 2 0 14 14\n",
"24 MI 14 14 14 12 0 14 14\n",
"32 NE 14 14 14 11 0 14 14\n",
"34 NJ 14 14 9 12 8 14 14\n",
"36 NV 14 14 14 1 3 14 14\n",
"38 OH 14 14 14 12 0 14 14\n",
"46 TN 14 14 8 0 0 14 14\n",
"49 VA 14 14 14 5 4 13 14\n",
"0 AK 13 13 13 7 0 13 13\n",
"2 AR 13 13 13 13 0 13 13\n",
"9 DE 13 13 13 11 0 13 13\n",
"14 IA 13 13 13 8 0 13 13\n",
"17 IN 13 13 9 0 5 13 13\n",
"18 KS 13 13 13 5 5 13 13\n",
"19 KY 13 13 13 1 3 13 13\n",
"25 MN 13 13 13 0 0 13 13\n",
"35 NM 13 13 13 4 0 13 13\n",
"41 PA 13 13 8 5 0 12 13\n",
"51 VT 13 13 13 0 0 13 13\n",
"54 WV 13 12 13 13 4 13 13\n",
"1 AL 12 11 9 4 4 12 12\n",
"7 CT 12 11 11 1 0 12 12\n",
"13 HI 12 12 1 1 0 12 12\n",
"15 ID 12 12 12 0 0 12 12\n",
"20 LA 12 12 11 0 4 12 12\n",
"23 ME 12 12 12 6 0 12 12\n",
"26 MO 12 12 7 0 5 12 12\n",
"28 MS 12 12 8 0 0 12 12\n",
"29 MT 12 12 12 5 0 12 12\n",
"31 ND 12 11 12 8 6 12 12\n",
"39 OK 12 12 11 11 0 12 12\n",
"43 RI 12 12 11 11 0 12 12\n",
"45 SD 12 12 12 12 1 12 12\n",
"48 UT 12 12 7 0 4 12 12\n",
"55 WY 12 12 3 1 0 12 12\n",
"3 AS 3 3 0 0 1 3 3\n",
"12 GU 3 3 3 0 0 3 3\n",
"27 MP 3 3 0 0 1 3 3\n",
"42 PR 3 3 3 2 0 3 3\n",
"50 VI 3 3 0 0 1 3 3"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"summary_df = data_df.groupby('state').count()\n",
"summary_df.reset_index().sort_values(['date', 'state'], ascending=[False, True])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
%% Cell type:code id: tags:
```
python
import
pandas
as
pd
import
altair
as
alt
```
%% Cell type:markdown id: tags:
# Look at the metadata
%% Cell type:code id: tags:
```
python
metadata_df
=
pd
.
read_json
(
'
../../data/covidtracking/states-metadata.json
'
)
```
%% Cell type:code id: tags:
```
python
metadata_df
.
head
()
```
%% Output
state dataSite \
0 AK http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-...
1 AL http://www.alabamapublichealth.gov/infectiousd...
2 AR https://www.healthy.arkansas.gov/programs-serv...
3 AZ https://www.azdhs.gov/preparedness/epidemiolog...
4 CA https://www.cdph.ca.gov/Programs/CID/DCDC/Page...
covid19Site twitter \
0 http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-... @Alaska_DHSS
1 http://www.alabamapublichealth.gov/infectiousd... @alpublichealth
2 https://www.healthy.arkansas.gov/programs-serv... @adhpio
3 https://www.azdhs.gov/preparedness/epidemiolog... @azdhs
4 https://www.cdph.ca.gov/Programs/CID/DCDC/Page... @CAPublicHealth
pui pum notes \
0 All data False Unclear if their reported number means "person...
1 No data False Last negative count from 3/16.
2 All data True Pending = "PUIs"
3 All data False Negative = “Ruled Out”. Our total is slightly ...
4 Only positives False Only positives reported regularly. Add deaths ...
name
0 Alaska
1 Alabama
2 Arkansas
3 Arizona
4 California
%% Cell type:markdown id: tags:
# Look at the data
%% Cell type:code id: tags:
```
python
data_df
=
pd
.
read_json
(
'
../../data/covidtracking/states-daily.json
'
)
data_df
[
'
date
'
]
=
pd
.
to_datetime
(
data_df
[
'
date
'
],
format
=
"
%Y%m%d
"
)
```
%% Cell type:code id: tags:
```
python
data_df
.
head
()
```
%% Output
date state positive negative pending death total \
0 2020-03-18 AK 6.0 406.0 NaN NaN 412.0
1 2020-03-18 AL 46.0 28.0 NaN 0.0 74.0
2 2020-03-18 AR 33.0 236.0 50.0 NaN 319.0
3 2020-03-18 AZ 28.0 148.0 102.0 0.0 278.0
4 2020-03-18 CA 611.0 7981.0 NaN 13.0 8592.0
dateChecked
0 2020-03-18T20:00:00Z
1 2020-03-18T20:00:00Z
2 2020-03-18T20:00:00Z
3 2020-03-18T20:00:00Z
4 2020-03-18T20:00:00Z
%% Cell type:markdown id: tags:
## How many data points per state?
%% Cell type:code id: tags:
```
python
summary_df
=
data_df
.
groupby
(
'
state
'
).
count
()
summary_df
.
reset_index
().
sort_values
([
'
date
'
,
'
state
'
],
ascending
=
[
False
,
True
])
```
%% Output
state date positive negative pending death total dateChecked
4 AZ 15 15 15 15 6 15 15
5 CA 15 15 15 0 7 15 15
10 FL 15 15 15 14 8 15 15
11 GA 15 15 1 0 6 15 15
16 IL 15 15 15 12 2 15 15
21 MA 15 15 6 0 0 14 15
30 NC 15 15 7 2 3 15 15
33 NH 15 15 15 15 0 15 15
37 NY 15 15 13 4 4 15 15
40 OR 15 15 15 15 1 15 15
44 SC 15 15 15 3 3 15 15
47 TX 15 15 2 0 2 15 15
52 WA 15 15 13 2 8 15 15
53 WI 15 15 15 5 0 15 15
6 CO 14 14 14 4 5 14 14
8 DC 14 14 14 12 0 14 14
22 MD 14 14 14 2 0 14 14
24 MI 14 14 14 12 0 14 14
32 NE 14 14 14 11 0 14 14
34 NJ 14 14 9 12 8 14 14
36 NV 14 14 14 1 3 14 14
38 OH 14 14 14 12 0 14 14
46 TN 14 14 8 0 0 14 14
49 VA 14 14 14 5 4 13 14
0 AK 13 13 13 7 0 13 13
2 AR 13 13 13 13 0 13 13
9 DE 13 13 13 11 0 13 13
14 IA 13 13 13 8 0 13 13
17 IN 13 13 9 0 5 13 13
18 KS 13 13 13 5 5 13 13
19 KY 13 13 13 1 3 13 13
25 MN 13 13 13 0 0 13 13
35 NM 13 13 13 4 0 13 13
41 PA 13 13 8 5 0 12 13
51 VT 13 13 13 0 0 13 13
54 WV 13 12 13 13 4 13 13
1 AL 12 11 9 4 4 12 12
7 CT 12 11 11 1 0 12 12
13 HI 12 12 1 1 0 12 12
15 ID 12 12 12 0 0 12 12
20 LA 12 12 11 0 4 12 12
23 ME 12 12 12 6 0 12 12
26 MO 12 12 7 0 5 12 12
28 MS 12 12 8 0 0 12 12
29 MT 12 12 12 5 0 12 12
31 ND 12 11 12 8 6 12 12
39 OK 12 12 11 11 0 12 12
43 RI 12 12 11 11 0 12 12
45 SD 12 12 12 12 1 12 12
48 UT 12 12 7 0 4 12 12
55 WY 12 12 3 1 0 12 12
3 AS 3 3 0 0 1 3 3
12 GU 3 3 3 0 0 3 3
27 MP 3 3 0 0 1 3 3
42 PR 3 3 3 2 0 3 3
50 VI 3 3 0 0 1 3 3
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment