{ "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>covid19SiteOld</th>\n", " <th>covid19Site</th>\n", " <th>covid19SiteSecondary</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>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>We count the reported number as \"persons teste...</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>https://alpublichealth.maps.arcgis.com/apps/op...</td>\n", " <td>None</td>\n", " <td>@alpublichealth</td>\n", " <td>No data</td>\n", " <td>False</td>\n", " <td>Last negative count from 3/16. Last update tim...</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://adem.maps.arcgis.com/apps/opsdashboard...</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>The state reports \"specimens\" tested, but it a...</td>\n", " <td>Arkansas</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>AS</td>\n", " <td>http://www.samoagovt.ws/2020/03/ministry-of-he...</td>\n", " <td>http://www.samoagovt.ws/category/latest-news/</td>\n", " <td>https://www.facebook.com/amsamgov/</td>\n", " <td>None</td>\n", " <td>No Data</td>\n", " <td>False</td>\n", " <td>American Samoa: No data, no confirmed cases yet.</td>\n", " <td>American Samoa</td>\n", " </tr>\n", " <tr>\n", " <th>4</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>None</td>\n", " <td>@azdhs</td>\n", " <td>All data</td>\n", " <td>False</td>\n", " <td>Negative = “Ruled Out”. Negatives are from pub...</td>\n", " <td>Arizona</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " state covid19SiteOld \\\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 AS http://www.samoagovt.ws/2020/03/ministry-of-he... \n", "4 AZ https://www.azdhs.gov/preparedness/epidemiolog... \n", "\n", " covid19Site \\\n", "0 http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-... \n", "1 https://alpublichealth.maps.arcgis.com/apps/op... \n", "2 https://adem.maps.arcgis.com/apps/opsdashboard... \n", "3 http://www.samoagovt.ws/category/latest-news/ \n", "4 https://www.azdhs.gov/preparedness/epidemiolog... \n", "\n", " covid19SiteSecondary twitter \\\n", "0 http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-... @Alaska_DHSS \n", "1 None @alpublichealth \n", "2 https://www.healthy.arkansas.gov/programs-serv... @adhpio \n", "3 https://www.facebook.com/amsamgov/ None \n", "4 None @azdhs \n", "\n", " pui pum notes \\\n", "0 All data False We count the reported number as \"persons teste... \n", "1 No data False Last negative count from 3/16. Last update tim... \n", "2 All data True The state reports \"specimens\" tested, but it a... \n", "3 No Data False American Samoa: No data, no confirmed cases yet. \n", "4 All data False Negative = “Ruled Out”. Negatives are from pub... \n", "\n", " name \n", "0 Alaska \n", "1 Alabama \n", "2 Arkansas \n", "3 American Samoa \n", "4 Arizona " ] }, "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": 5, "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>hospitalized</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-23</td>\n", " <td>AK</td>\n", " <td>22.0</td>\n", " <td>946.0</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>968</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>2020-03-23</td>\n", " <td>AL</td>\n", " <td>167.0</td>\n", " <td>1665.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>1832</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>2020-03-23</td>\n", " <td>AR</td>\n", " <td>174.0</td>\n", " <td>906.0</td>\n", " <td>0.0</td>\n", " <td>13.0</td>\n", " <td>0.0</td>\n", " <td>1080</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>2020-03-23</td>\n", " <td>AS</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>2020-03-23</td>\n", " <td>AZ</td>\n", " <td>265.0</td>\n", " <td>309.0</td>\n", " <td>6.0</td>\n", " <td>NaN</td>\n", " <td>2.0</td>\n", " <td>580</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " date state positive negative pending hospitalized death total \\\n", "0 2020-03-23 AK 22.0 946.0 NaN 0.0 NaN 968 \n", "1 2020-03-23 AL 167.0 1665.0 NaN NaN 0.0 1832 \n", "2 2020-03-23 AR 174.0 906.0 0.0 13.0 0.0 1080 \n", "3 2020-03-23 AS NaN NaN NaN NaN 0.0 0 \n", "4 2020-03-23 AZ 265.0 309.0 6.0 NaN 2.0 580 \n", "\n", " dateChecked \n", "0 2020-03-23T20:00:00Z \n", "1 2020-03-23T20:00:00Z \n", "2 2020-03-23T20:00:00Z \n", "3 2020-03-23T20:00:00Z \n", "4 2020-03-23T20:00:00Z " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Daily counts and totals" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# compute daily differences\n", "tdf = data_df.sort_values(['state', 'date'], ascending=[True, False]).set_index(['state', 'date'])\n", "diffs_df = tdf[['positive', 'negative', 'death']].groupby(level='state').diff(periods=-1).dropna(how='all')\n", "tdf_diff=tdf.join(diffs_df, rsuffix='_diff').reset_index()\n", "\n", "# \"Normalizing\" the totals\n", "tdf_diff['total_10'] = tdf_diff['total']/10." ] }, { "cell_type": "code", "execution_count": 7, "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></th>\n", " <th>positive</th>\n", " <th>negative</th>\n", " <th>pending</th>\n", " <th>hospitalized</th>\n", " <th>death</th>\n", " <th>total</th>\n", " <th>dateChecked</th>\n", " </tr>\n", " <tr>\n", " <th>state</th>\n", " <th>date</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 rowspan=\"5\" valign=\"top\">AK</th>\n", " <th>2020-03-23</th>\n", " <td>22.0</td>\n", " <td>946.0</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>968</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2020-03-22</th>\n", " <td>22.0</td>\n", " <td>946.0</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>968</td>\n", " <td>2020-03-22T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2020-03-21</th>\n", " <td>14.0</td>\n", " <td>758.0</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>772</td>\n", " <td>2020-03-21T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2020-03-20</th>\n", " <td>12.0</td>\n", " <td>686.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>698</td>\n", " <td>2020-03-20T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2020-03-19</th>\n", " <td>6.0</td>\n", " <td>400.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>406</td>\n", " <td>2020-03-19T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>...</th>\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", " </tr>\n", " <tr>\n", " <th rowspan=\"5\" valign=\"top\">WY</th>\n", " <th>2020-03-11</th>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-11T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2020-03-10</th>\n", " <td>0.0</td>\n", " <td>0.0</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-10T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2020-03-09</th>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-09T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2020-03-08</th>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-08T20:00:00Z</td>\n", " </tr>\n", " <tr>\n", " <th>2020-03-07</th>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-07T21:00:00Z</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>981 rows × 7 columns</p>\n", "</div>" ], "text/plain": [ " positive negative pending hospitalized death total \\\n", "state date \n", "AK 2020-03-23 22.0 946.0 NaN 0.0 NaN 968 \n", " 2020-03-22 22.0 946.0 NaN 0.0 NaN 968 \n", " 2020-03-21 14.0 758.0 NaN 0.0 NaN 772 \n", " 2020-03-20 12.0 686.0 NaN NaN NaN 698 \n", " 2020-03-19 6.0 400.0 NaN NaN NaN 406 \n", "... ... ... ... ... ... ... \n", "WY 2020-03-11 0.0 NaN NaN NaN NaN 0 \n", " 2020-03-10 0.0 0.0 0.0 NaN NaN 0 \n", " 2020-03-09 0.0 NaN NaN NaN NaN 0 \n", " 2020-03-08 0.0 NaN NaN NaN NaN 0 \n", " 2020-03-07 0.0 NaN NaN NaN NaN 0 \n", "\n", " dateChecked \n", "state date \n", "AK 2020-03-23 2020-03-23T20:00:00Z \n", " 2020-03-22 2020-03-22T20:00:00Z \n", " 2020-03-21 2020-03-21T20:00:00Z \n", " 2020-03-20 2020-03-20T20:00:00Z \n", " 2020-03-19 2020-03-19T20:00:00Z \n", "... ... \n", "WY 2020-03-11 2020-03-11T20:00:00Z \n", " 2020-03-10 2020-03-10T20:00:00Z \n", " 2020-03-09 2020-03-09T20:00:00Z \n", " 2020-03-08 2020-03-08T20:00:00Z \n", " 2020-03-07 2020-03-07T21:00:00Z \n", "\n", "[981 rows x 7 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tdf" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>state</th>\n", " <th>date</th>\n", " <th>positive</th>\n", " <th>negative</th>\n", " <th>pending</th>\n", " <th>hospitalized</th>\n", " <th>death</th>\n", " <th>total</th>\n", " <th>dateChecked</th>\n", " <th>positive_diff</th>\n", " <th>negative_diff</th>\n", " <th>death_diff</th>\n", " <th>total_10</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>AK</td>\n", " <td>2020-03-23</td>\n", " <td>22.0</td>\n", " <td>946.0</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>968</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " <td>0.0</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>96.8</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>AK</td>\n", " <td>2020-03-22</td>\n", " <td>22.0</td>\n", " <td>946.0</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>968</td>\n", " <td>2020-03-22T20:00:00Z</td>\n", " <td>8.0</td>\n", " <td>188.0</td>\n", " <td>NaN</td>\n", " <td>96.8</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>AK</td>\n", " <td>2020-03-21</td>\n", " <td>14.0</td>\n", " <td>758.0</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>772</td>\n", " <td>2020-03-21T20:00:00Z</td>\n", " <td>2.0</td>\n", " <td>72.0</td>\n", " <td>NaN</td>\n", " <td>77.2</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>AK</td>\n", " <td>2020-03-20</td>\n", " <td>12.0</td>\n", " <td>686.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>698</td>\n", " <td>2020-03-20T20:00:00Z</td>\n", " <td>6.0</td>\n", " <td>286.0</td>\n", " <td>NaN</td>\n", " <td>69.8</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>AK</td>\n", " <td>2020-03-19</td>\n", " <td>6.0</td>\n", " <td>400.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>406</td>\n", " <td>2020-03-19T20:00:00Z</td>\n", " <td>0.0</td>\n", " <td>-6.0</td>\n", " <td>NaN</td>\n", " <td>40.6</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", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>976</th>\n", " <td>WY</td>\n", " <td>2020-03-11</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-11T20:00:00Z</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>977</th>\n", " <td>WY</td>\n", " <td>2020-03-10</td>\n", " <td>0.0</td>\n", " <td>0.0</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-10T20:00:00Z</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>978</th>\n", " <td>WY</td>\n", " <td>2020-03-09</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-09T20:00:00Z</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>979</th>\n", " <td>WY</td>\n", " <td>2020-03-08</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-08T20:00:00Z</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>980</th>\n", " <td>WY</td>\n", " <td>2020-03-07</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0</td>\n", " <td>2020-03-07T21:00:00Z</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>981 rows × 13 columns</p>\n", "</div>" ], "text/plain": [ " state date positive negative pending hospitalized death total \\\n", "0 AK 2020-03-23 22.0 946.0 NaN 0.0 NaN 968 \n", "1 AK 2020-03-22 22.0 946.0 NaN 0.0 NaN 968 \n", "2 AK 2020-03-21 14.0 758.0 NaN 0.0 NaN 772 \n", "3 AK 2020-03-20 12.0 686.0 NaN NaN NaN 698 \n", "4 AK 2020-03-19 6.0 400.0 NaN NaN NaN 406 \n", ".. ... ... ... ... ... ... ... ... \n", "976 WY 2020-03-11 0.0 NaN NaN NaN NaN 0 \n", "977 WY 2020-03-10 0.0 0.0 0.0 NaN NaN 0 \n", "978 WY 2020-03-09 0.0 NaN NaN NaN NaN 0 \n", "979 WY 2020-03-08 0.0 NaN NaN NaN NaN 0 \n", "980 WY 2020-03-07 0.0 NaN NaN NaN NaN 0 \n", "\n", " dateChecked positive_diff negative_diff death_diff total_10 \n", "0 2020-03-23T20:00:00Z 0.0 0.0 NaN 96.8 \n", "1 2020-03-22T20:00:00Z 8.0 188.0 NaN 96.8 \n", "2 2020-03-21T20:00:00Z 2.0 72.0 NaN 77.2 \n", "3 2020-03-20T20:00:00Z 6.0 286.0 NaN 69.8 \n", "4 2020-03-19T20:00:00Z 0.0 -6.0 NaN 40.6 \n", ".. ... ... ... ... ... \n", "976 2020-03-11T20:00:00Z 0.0 NaN NaN 0.0 \n", "977 2020-03-10T20:00:00Z 0.0 NaN NaN 0.0 \n", "978 2020-03-09T20:00:00Z 0.0 NaN NaN 0.0 \n", "979 2020-03-08T20:00:00Z 0.0 NaN NaN 0.0 \n", "980 2020-03-07T21:00:00Z NaN NaN NaN 0.0 \n", "\n", "[981 rows x 13 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tdf_diff" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "<div id=\"altair-viz-bf0dc4cb9a2f4f62a19f7f9455255381\"></div>\n", "<script type=\"text/javascript\">\n", " (function(spec, embedOpt){\n", " const outputDiv = document.getElementById(\"altair-viz-bf0dc4cb9a2f4f62a19f7f9455255381\");\n", " const paths = {\n", " \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n", " \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n", " \"vega-lite\": \"https://cdn.jsdelivr.net/npm//vega-lite@4.0.2?noext\",\n", " \"vega-embed\": \"https://cdn.jsdelivr.net/npm//vega-embed@6?noext\",\n", " };\n", "\n", " function loadScript(lib) {\n", " return new Promise(function(resolve, reject) {\n", " var s = document.createElement('script');\n", " s.src = paths[lib];\n", " s.async = true;\n", " s.onload = () => resolve(paths[lib]);\n", " s.onerror = () => reject(`Error loading script: ${paths[lib]}`);\n", " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", " });\n", " }\n", "\n", " function showError(err) {\n", " outputDiv.innerHTML = `<div class=\"error\" style=\"color:red;\">${err}</div>`;\n", " throw err;\n", " }\n", "\n", " function displayChart(vegaEmbed) {\n", " vegaEmbed(outputDiv, spec, embedOpt)\n", " .catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));\n", " }\n", "\n", " if(typeof define === \"function\" && define.amd) {\n", " requirejs.config({paths});\n", " require([\"vega-embed\"], displayChart, err => showError(`Error loading script: ${err.message}`));\n", " } else if (typeof vegaEmbed === \"function\") {\n", " displayChart(vegaEmbed);\n", " } else {\n", " loadScript(\"vega\")\n", " .then(() => loadScript(\"vega-lite\"))\n", " .then(() => loadScript(\"vega-embed\"))\n", " .catch(showError)\n", " .then(() => displayChart(vegaEmbed));\n", " }\n", " })({\"config\": {\"view\": {\"continuousWidth\": 400, \"continuousHeight\": 300}}, \"hconcat\": [{\"layer\": [{\"mark\": {\"type\": \"bar\", \"size\": 10}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Daily positive\"}, \"field\": \"daily_positive\"}}, \"height\": 150, \"title\": \"WA\", \"width\": 250}, {\"layer\": [{\"mark\": {\"type\": \"line\", \"color\": \"red\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Total/10\"}, \"field\": \"total_10\"}}, \"height\": 150, \"title\": \"WA\", \"width\": 250}, {\"mark\": {\"type\": \"line\", \"color\": \"orange\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Positive\"}, \"field\": \"positive\"}}, \"height\": 150, \"title\": \"WA\", \"width\": 250}]}], \"data\": {\"name\": \"data-c6782400083e2467b17c61884335e378\"}, \"resolve\": {\"scale\": {\"y\": \"independent\"}}}, {\"layer\": [{\"mark\": {\"type\": \"bar\", \"size\": 10}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Daily positive\"}, \"field\": \"daily_positive\"}}, \"height\": 150, \"title\": \"CA\", \"width\": 250}, {\"layer\": [{\"mark\": {\"type\": \"line\", \"color\": \"red\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Total/10\"}, \"field\": \"total_10\"}}, \"height\": 150, \"title\": \"CA\", \"width\": 250}, {\"mark\": {\"type\": \"line\", \"color\": \"orange\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Positive\"}, \"field\": \"positive\"}}, \"height\": 150, \"title\": \"CA\", \"width\": 250}]}], \"data\": {\"name\": \"data-eef4098b7abaaa36c9f3d5acf94f9e4e\"}, \"resolve\": {\"scale\": {\"y\": \"independent\"}}}, {\"layer\": [{\"mark\": {\"type\": \"bar\", \"size\": 10}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Daily positive\"}, \"field\": \"daily_positive\"}}, \"height\": 150, \"title\": \"NY\", \"width\": 250}, {\"layer\": [{\"mark\": {\"type\": \"line\", \"color\": \"red\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Total/10\"}, \"field\": \"total_10\"}}, \"height\": 150, \"title\": \"NY\", \"width\": 250}, {\"mark\": {\"type\": \"line\", \"color\": \"orange\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Positive\"}, \"field\": \"positive\"}}, \"height\": 150, \"title\": \"NY\", \"width\": 250}]}], \"data\": {\"name\": \"data-5fcc74c83ca5bc4a7914311e37ca7698\"}, \"resolve\": {\"scale\": {\"y\": \"independent\"}}}], \"$schema\": \"https://vega.github.io/schema/vega-lite/v4.0.2.json\", \"datasets\": {\"data-c6782400083e2467b17c61884335e378\": [{\"state\": \"WA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1996.0, \"negative\": 28879.0, \"pending\": null, \"hospitalized\": null, \"death\": 95.0, \"total\": 30875, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"positive_diff\": 203.0, \"negative_diff\": 3551.0, \"death_diff\": 1.0, \"total_10\": 3087.5, \"daily_positive\": 203.0}, {\"state\": \"WA\", \"date\": \"2020-03-22T00:00:00\", \"positive\": 1793.0, \"negative\": 25328.0, \"pending\": null, \"hospitalized\": null, \"death\": 94.0, \"total\": 27121, \"dateChecked\": \"2020-03-22T20:00:00Z\", \"positive_diff\": 269.0, \"negative_diff\": 3609.0, \"death_diff\": 11.0, \"total_10\": 2712.1, \"daily_positive\": 269.0}, {\"state\": \"WA\", \"date\": \"2020-03-21T00:00:00\", \"positive\": 1524.0, \"negative\": 21719.0, \"pending\": null, \"hospitalized\": null, \"death\": 83.0, \"total\": 23243, \"dateChecked\": \"2020-03-21T20:00:00Z\", \"positive_diff\": 148.0, \"negative_diff\": 2383.0, \"death_diff\": 9.0, \"total_10\": 2324.3, \"daily_positive\": 148.0}, {\"state\": \"WA\", \"date\": \"2020-03-20T00:00:00\", \"positive\": 1376.0, \"negative\": 19336.0, \"pending\": null, \"hospitalized\": null, \"death\": 74.0, \"total\": 20712, \"dateChecked\": \"2020-03-20T20:00:00Z\", \"positive_diff\": 189.0, \"negative_diff\": 3418.0, \"death_diff\": 8.0, \"total_10\": 2071.2, \"daily_positive\": 189.0}, {\"state\": \"WA\", \"date\": \"2020-03-19T00:00:00\", \"positive\": 1187.0, \"negative\": 15918.0, \"pending\": null, \"hospitalized\": null, \"death\": 66.0, \"total\": 17105, \"dateChecked\": \"2020-03-19T20:00:00Z\", \"positive_diff\": 175.0, \"negative_diff\": 2801.0, \"death_diff\": 14.0, \"total_10\": 1710.5, \"daily_positive\": 175.0}, {\"state\": \"WA\", \"date\": \"2020-03-18T00:00:00\", \"positive\": 1012.0, \"negative\": 13117.0, \"pending\": null, \"hospitalized\": null, \"death\": 52.0, \"total\": 14129, \"dateChecked\": \"2020-03-18T20:00:00Z\", \"positive_diff\": 108.0, \"negative_diff\": 1535.0, \"death_diff\": 4.0, \"total_10\": 1412.9, \"daily_positive\": 108.0}, {\"state\": \"WA\", \"date\": \"2020-03-17T00:00:00\", \"positive\": 904.0, \"negative\": 11582.0, \"pending\": null, \"hospitalized\": null, \"death\": 48.0, \"total\": 12486, \"dateChecked\": \"2020-03-17T20:00:00Z\", \"positive_diff\": 135.0, \"negative_diff\": 2131.0, \"death_diff\": 6.0, \"total_10\": 1248.6, \"daily_positive\": 135.0}, {\"state\": \"WA\", \"date\": \"2020-03-16T00:00:00\", \"positive\": 769.0, \"negative\": 9451.0, \"pending\": null, \"hospitalized\": null, \"death\": 42.0, \"total\": 10220, \"dateChecked\": \"2020-03-16T20:00:00Z\", \"positive_diff\": 127.0, \"negative_diff\": 2329.0, \"death_diff\": 2.0, \"total_10\": 1022.0, \"daily_positive\": 127.0}, {\"state\": \"WA\", \"date\": \"2020-03-15T00:00:00\", \"positive\": 642.0, \"negative\": 7122.0, \"pending\": null, \"hospitalized\": null, \"death\": 40.0, \"total\": 7764, \"dateChecked\": \"2020-03-15T20:00:00Z\", \"positive_diff\": 74.0, \"negative_diff\": 1121.0, \"death_diff\": 3.0, \"total_10\": 776.4, \"daily_positive\": 74.0}, {\"state\": \"WA\", \"date\": \"2020-03-14T00:00:00\", \"positive\": 568.0, \"negative\": 6001.0, \"pending\": null, \"hospitalized\": null, \"death\": 37.0, \"total\": 6569, \"dateChecked\": \"2020-03-14T20:00:00Z\", \"positive_diff\": 111.0, \"negative_diff\": 1651.0, \"death_diff\": 6.0, \"total_10\": 656.9, \"daily_positive\": 111.0}, {\"state\": \"WA\", \"date\": \"2020-03-13T00:00:00\", \"positive\": 457.0, \"negative\": 4350.0, \"pending\": null, \"hospitalized\": null, \"death\": 31.0, \"total\": 4807, \"dateChecked\": \"2020-03-13T20:00:00Z\", \"positive_diff\": 120.0, \"negative_diff\": 1313.0, \"death_diff\": 2.0, \"total_10\": 480.7, \"daily_positive\": 120.0}, {\"state\": \"WA\", \"date\": \"2020-03-12T00:00:00\", \"positive\": 337.0, \"negative\": 3037.0, \"pending\": null, \"hospitalized\": null, \"death\": 29.0, \"total\": 3403, \"dateChecked\": \"2020-03-12T20:00:00Z\", \"positive_diff\": 70.0, \"negative_diff\": 862.0, \"death_diff\": 5.0, \"total_10\": 340.3, \"daily_positive\": 70.0}, {\"state\": \"WA\", \"date\": \"2020-03-11T00:00:00\", \"positive\": 267.0, \"negative\": 2175.0, \"pending\": null, \"hospitalized\": null, \"death\": 24.0, \"total\": 2466, \"dateChecked\": \"2020-03-11T20:00:00Z\", \"positive_diff\": 105.0, \"negative_diff\": 1065.0, \"death_diff\": null, \"total_10\": 246.6, \"daily_positive\": 105.0}, {\"state\": \"WA\", \"date\": \"2020-03-10T00:00:00\", \"positive\": 162.0, \"negative\": 1110.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 1272, \"dateChecked\": \"2020-03-10T20:00:00Z\", \"positive_diff\": 26.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 127.2, \"daily_positive\": 26.0}, {\"state\": \"WA\", \"date\": \"2020-03-09T00:00:00\", \"positive\": 136.0, \"negative\": 1110.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 1246, \"dateChecked\": \"2020-03-09T20:00:00Z\", \"positive_diff\": 34.0, \"negative_diff\": 470.0, \"death_diff\": null, \"total_10\": 124.6, \"daily_positive\": 34.0}, {\"state\": \"WA\", \"date\": \"2020-03-08T00:00:00\", \"positive\": 102.0, \"negative\": 640.0, \"pending\": 60.0, \"hospitalized\": null, \"death\": null, \"total\": 802, \"dateChecked\": \"2020-03-08T20:00:00Z\", \"positive_diff\": 0.0, \"negative_diff\": 270.0, \"death_diff\": null, \"total_10\": 80.2, \"daily_positive\": 0.0}, {\"state\": \"WA\", \"date\": \"2020-03-07T00:00:00\", \"positive\": 102.0, \"negative\": 370.0, \"pending\": 66.0, \"hospitalized\": null, \"death\": null, \"total\": 538, \"dateChecked\": \"2020-03-07T21:00:00Z\", \"positive_diff\": 23.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 53.8, \"daily_positive\": 23.0}, {\"state\": \"WA\", \"date\": \"2020-03-06T00:00:00\", \"positive\": 79.0, \"negative\": 370.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 449, \"dateChecked\": \"2020-03-06T21:00:00Z\", \"positive_diff\": 9.0, \"negative_diff\": null, \"death_diff\": null, \"total_10\": 44.9, \"daily_positive\": 9.0}, {\"state\": \"WA\", \"date\": \"2020-03-05T00:00:00\", \"positive\": 70.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 70, \"dateChecked\": \"2020-03-05T21:00:00Z\", \"positive_diff\": 31.0, \"negative_diff\": null, \"death_diff\": null, \"total_10\": 7.0, \"daily_positive\": 31.0}, {\"state\": \"WA\", \"date\": \"2020-03-04T00:00:00\", \"positive\": 39.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 39, \"dateChecked\": \"2020-03-04T21:00:00Z\", \"positive_diff\": null, \"negative_diff\": null, \"death_diff\": null, \"total_10\": 3.9, \"daily_positive\": null}], \"data-eef4098b7abaaa36c9f3d5acf94f9e4e\": [{\"state\": \"CA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1733.0, \"negative\": 12567.0, \"pending\": 12100.0, \"hospitalized\": null, \"death\": 27.0, \"total\": 26400, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"positive_diff\": 197.0, \"negative_diff\": 1263.0, \"death_diff\": 0.0, \"total_10\": 2640.0, \"daily_positive\": 197.0}, {\"state\": \"CA\", \"date\": \"2020-03-22T00:00:00\", \"positive\": 1536.0, \"negative\": 11304.0, \"pending\": null, \"hospitalized\": null, \"death\": 27.0, \"total\": 12840, \"dateChecked\": \"2020-03-22T20:00:00Z\", \"positive_diff\": 257.0, \"negative_diff\": 55.0, \"death_diff\": 3.0, \"total_10\": 1284.0, \"daily_positive\": 257.0}, {\"state\": \"CA\", \"date\": \"2020-03-21T00:00:00\", \"positive\": 1279.0, \"negative\": 11249.0, \"pending\": null, \"hospitalized\": null, \"death\": 24.0, \"total\": 12528, \"dateChecked\": \"2020-03-21T20:00:00Z\", \"positive_diff\": 216.0, \"negative_diff\": 825.0, \"death_diff\": 4.0, \"total_10\": 1252.8, \"daily_positive\": 216.0}, {\"state\": \"CA\", \"date\": \"2020-03-20T00:00:00\", \"positive\": 1063.0, \"negative\": 10424.0, \"pending\": null, \"hospitalized\": null, \"death\": 20.0, \"total\": 11487, \"dateChecked\": \"2020-03-20T20:00:00Z\", \"positive_diff\": 139.0, \"negative_diff\": 1637.0, \"death_diff\": 2.0, \"total_10\": 1148.7, \"daily_positive\": 139.0}, {\"state\": \"CA\", \"date\": \"2020-03-19T00:00:00\", \"positive\": 924.0, \"negative\": 8787.0, \"pending\": null, \"hospitalized\": null, \"death\": 18.0, \"total\": 9711, \"dateChecked\": \"2020-03-19T20:00:00Z\", \"positive_diff\": 313.0, \"negative_diff\": 806.0, \"death_diff\": 5.0, \"total_10\": 971.1, \"daily_positive\": 313.0}, {\"state\": \"CA\", \"date\": \"2020-03-18T00:00:00\", \"positive\": 611.0, \"negative\": 7981.0, \"pending\": null, \"hospitalized\": null, \"death\": 13.0, \"total\": 8592, \"dateChecked\": \"2020-03-18T20:00:00Z\", \"positive_diff\": 128.0, \"negative_diff\": 0.0, \"death_diff\": 2.0, \"total_10\": 859.2, \"daily_positive\": 128.0}, {\"state\": \"CA\", \"date\": \"2020-03-17T00:00:00\", \"positive\": 483.0, \"negative\": 7981.0, \"pending\": null, \"hospitalized\": null, \"death\": 11.0, \"total\": 8407, \"dateChecked\": \"2020-03-17T20:00:00Z\", \"positive_diff\": 148.0, \"negative_diff\": 0.0, \"death_diff\": 5.0, \"total_10\": 840.7, \"daily_positive\": 148.0}, {\"state\": \"CA\", \"date\": \"2020-03-16T00:00:00\", \"positive\": 335.0, \"negative\": 7981.0, \"pending\": null, \"hospitalized\": null, \"death\": 6.0, \"total\": 8316, \"dateChecked\": \"2020-03-16T20:00:00Z\", \"positive_diff\": 42.0, \"negative_diff\": 7065.0, \"death_diff\": 1.0, \"total_10\": 831.6, \"daily_positive\": 42.0}, {\"state\": \"CA\", \"date\": \"2020-03-15T00:00:00\", \"positive\": 293.0, \"negative\": 916.0, \"pending\": null, \"hospitalized\": null, \"death\": 5.0, \"total\": 1209, \"dateChecked\": \"2020-03-15T20:00:00Z\", \"positive_diff\": 41.0, \"negative_diff\": 0.0, \"death_diff\": 0.0, \"total_10\": 120.9, \"daily_positive\": 41.0}, {\"state\": \"CA\", \"date\": \"2020-03-14T00:00:00\", \"positive\": 252.0, \"negative\": 916.0, \"pending\": null, \"hospitalized\": null, \"death\": 5.0, \"total\": 1168, \"dateChecked\": \"2020-03-14T20:00:00Z\", \"positive_diff\": 50.0, \"negative_diff\": 0.0, \"death_diff\": 1.0, \"total_10\": 116.8, \"daily_positive\": 50.0}, {\"state\": \"CA\", \"date\": \"2020-03-13T00:00:00\", \"positive\": 202.0, \"negative\": 916.0, \"pending\": null, \"hospitalized\": null, \"death\": 4.0, \"total\": 1118, \"dateChecked\": \"2020-03-13T20:00:00Z\", \"positive_diff\": 0.0, \"negative_diff\": 0.0, \"death_diff\": 0.0, \"total_10\": 111.8, \"daily_positive\": 0.0}, {\"state\": \"CA\", \"date\": \"2020-03-12T00:00:00\", \"positive\": 202.0, \"negative\": 916.0, \"pending\": null, \"hospitalized\": null, \"death\": 4.0, \"total\": 1118, \"dateChecked\": \"2020-03-12T20:00:00Z\", \"positive_diff\": 45.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 111.8, \"daily_positive\": 45.0}, {\"state\": \"CA\", \"date\": \"2020-03-11T00:00:00\", \"positive\": 157.0, \"negative\": 916.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 1073, \"dateChecked\": \"2020-03-11T20:00:00Z\", \"positive_diff\": 24.0, \"negative_diff\": 226.0, \"death_diff\": null, \"total_10\": 107.3, \"daily_positive\": 24.0}, {\"state\": \"CA\", \"date\": \"2020-03-10T00:00:00\", \"positive\": 133.0, \"negative\": 690.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 823, \"dateChecked\": \"2020-03-10T20:00:00Z\", \"positive_diff\": 19.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 82.3, \"daily_positive\": 19.0}, {\"state\": \"CA\", \"date\": \"2020-03-09T00:00:00\", \"positive\": 114.0, \"negative\": 690.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 804, \"dateChecked\": \"2020-03-09T20:00:00Z\", \"positive_diff\": 26.0, \"negative_diff\": 228.0, \"death_diff\": null, \"total_10\": 80.4, \"daily_positive\": 26.0}, {\"state\": \"CA\", \"date\": \"2020-03-08T00:00:00\", \"positive\": 88.0, \"negative\": 462.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 550, \"dateChecked\": \"2020-03-08T20:00:00Z\", \"positive_diff\": 19.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 55.0, \"daily_positive\": 19.0}, {\"state\": \"CA\", \"date\": \"2020-03-07T00:00:00\", \"positive\": 69.0, \"negative\": 462.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 531, \"dateChecked\": \"2020-03-07T21:00:00Z\", \"positive_diff\": 9.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 53.1, \"daily_positive\": 9.0}, {\"state\": \"CA\", \"date\": \"2020-03-06T00:00:00\", \"positive\": 60.0, \"negative\": 462.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 522, \"dateChecked\": \"2020-03-06T21:00:00Z\", \"positive_diff\": 7.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 52.2, \"daily_positive\": 7.0}, {\"state\": \"CA\", \"date\": \"2020-03-05T00:00:00\", \"positive\": 53.0, \"negative\": 462.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 515, \"dateChecked\": \"2020-03-05T21:00:00Z\", \"positive_diff\": 0.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 51.5, \"daily_positive\": 0.0}, {\"state\": \"CA\", \"date\": \"2020-03-04T00:00:00\", \"positive\": 53.0, \"negative\": 462.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 515, \"dateChecked\": \"2020-03-04T21:00:00Z\", \"positive_diff\": null, \"negative_diff\": null, \"death_diff\": null, \"total_10\": 51.5, \"daily_positive\": null}], \"data-5fcc74c83ca5bc4a7914311e37ca7698\": [{\"state\": \"NY\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 20875.0, \"negative\": 57414.0, \"pending\": null, \"hospitalized\": 2635.0, \"death\": 114.0, \"total\": 78289, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"positive_diff\": 5707.0, \"negative_diff\": 11181.0, \"death_diff\": 0.0, \"total_10\": 7828.9, \"daily_positive\": 5707.0}, {\"state\": \"NY\", \"date\": \"2020-03-22T00:00:00\", \"positive\": 15168.0, \"negative\": 46233.0, \"pending\": null, \"hospitalized\": 1974.0, \"death\": 114.0, \"total\": 61401, \"dateChecked\": \"2020-03-22T20:00:00Z\", \"positive_diff\": 4812.0, \"negative_diff\": 11152.0, \"death_diff\": 70.0, \"total_10\": 6140.1, \"daily_positive\": 4812.0}, {\"state\": \"NY\", \"date\": \"2020-03-21T00:00:00\", \"positive\": 10356.0, \"negative\": 35081.0, \"pending\": null, \"hospitalized\": 1603.0, \"death\": 44.0, \"total\": 45437, \"dateChecked\": \"2020-03-21T20:00:00Z\", \"positive_diff\": 3254.0, \"negative_diff\": 9756.0, \"death_diff\": 9.0, \"total_10\": 4543.7, \"daily_positive\": 3254.0}, {\"state\": \"NY\", \"date\": \"2020-03-20T00:00:00\", \"positive\": 7102.0, \"negative\": 25325.0, \"pending\": null, \"hospitalized\": null, \"death\": 35.0, \"total\": 32427, \"dateChecked\": \"2020-03-20T20:00:00Z\", \"positive_diff\": 2950.0, \"negative_diff\": 7193.0, \"death_diff\": 23.0, \"total_10\": 3242.7, \"daily_positive\": 2950.0}, {\"state\": \"NY\", \"date\": \"2020-03-19T00:00:00\", \"positive\": 4152.0, \"negative\": 18132.0, \"pending\": null, \"hospitalized\": null, \"death\": 12.0, \"total\": 22284, \"dateChecked\": \"2020-03-19T20:00:00Z\", \"positive_diff\": 1770.0, \"negative_diff\": 5917.0, \"death_diff\": 0.0, \"total_10\": 2228.4, \"daily_positive\": 1770.0}, {\"state\": \"NY\", \"date\": \"2020-03-18T00:00:00\", \"positive\": 2382.0, \"negative\": 12215.0, \"pending\": null, \"hospitalized\": null, \"death\": 12.0, \"total\": 14597, \"dateChecked\": \"2020-03-18T20:00:00Z\", \"positive_diff\": 682.0, \"negative_diff\": 6709.0, \"death_diff\": 5.0, \"total_10\": 1459.7, \"daily_positive\": 682.0}, {\"state\": \"NY\", \"date\": \"2020-03-17T00:00:00\", \"positive\": 1700.0, \"negative\": 5506.0, \"pending\": null, \"hospitalized\": null, \"death\": 7.0, \"total\": 7206, \"dateChecked\": \"2020-03-17T20:00:00Z\", \"positive_diff\": 750.0, \"negative_diff\": 963.0, \"death_diff\": 0.0, \"total_10\": 720.6, \"daily_positive\": 750.0}, {\"state\": \"NY\", \"date\": \"2020-03-16T00:00:00\", \"positive\": 950.0, \"negative\": 4543.0, \"pending\": null, \"hospitalized\": null, \"death\": 7.0, \"total\": 5493, \"dateChecked\": \"2020-03-16T20:00:00Z\", \"positive_diff\": 221.0, \"negative_diff\": 0.0, \"death_diff\": 4.0, \"total_10\": 549.3, \"daily_positive\": 221.0}, {\"state\": \"NY\", \"date\": \"2020-03-15T00:00:00\", \"positive\": 729.0, \"negative\": 4543.0, \"pending\": null, \"hospitalized\": null, \"death\": 3.0, \"total\": 5272, \"dateChecked\": \"2020-03-15T20:00:00Z\", \"positive_diff\": 205.0, \"negative_diff\": 1764.0, \"death_diff\": null, \"total_10\": 527.2, \"daily_positive\": 205.0}, {\"state\": \"NY\", \"date\": \"2020-03-14T00:00:00\", \"positive\": 524.0, \"negative\": 2779.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 3303, \"dateChecked\": \"2020-03-14T20:00:00Z\", \"positive_diff\": 103.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 330.3, \"daily_positive\": 103.0}, {\"state\": \"NY\", \"date\": \"2020-03-13T00:00:00\", \"positive\": 421.0, \"negative\": 2779.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 3200, \"dateChecked\": \"2020-03-13T20:00:00Z\", \"positive_diff\": 205.0, \"negative_diff\": null, \"death_diff\": null, \"total_10\": 320.0, \"daily_positive\": 205.0}, {\"state\": \"NY\", \"date\": \"2020-03-12T00:00:00\", \"positive\": 216.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 216, \"dateChecked\": \"2020-03-12T20:00:00Z\", \"positive_diff\": 0.0, \"negative_diff\": null, \"death_diff\": null, \"total_10\": 21.6, \"daily_positive\": 0.0}, {\"state\": \"NY\", \"date\": \"2020-03-11T00:00:00\", \"positive\": 216.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 216, \"dateChecked\": \"2020-03-11T20:00:00Z\", \"positive_diff\": 43.0, \"negative_diff\": null, \"death_diff\": null, \"total_10\": 21.6, \"daily_positive\": 43.0}, {\"state\": \"NY\", \"date\": \"2020-03-10T00:00:00\", \"positive\": 173.0, \"negative\": 92.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 265, \"dateChecked\": \"2020-03-10T20:00:00Z\", \"positive_diff\": 31.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 26.5, \"daily_positive\": 31.0}, {\"state\": \"NY\", \"date\": \"2020-03-09T00:00:00\", \"positive\": 142.0, \"negative\": 92.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 234, \"dateChecked\": \"2020-03-09T20:00:00Z\", \"positive_diff\": 37.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 23.4, \"daily_positive\": 37.0}, {\"state\": \"NY\", \"date\": \"2020-03-08T00:00:00\", \"positive\": 105.0, \"negative\": 92.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 197, \"dateChecked\": \"2020-03-08T20:00:00Z\", \"positive_diff\": 29.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 19.7, \"daily_positive\": 29.0}, {\"state\": \"NY\", \"date\": \"2020-03-07T00:00:00\", \"positive\": 76.0, \"negative\": 92.0, \"pending\": 236.0, \"hospitalized\": null, \"death\": null, \"total\": 404, \"dateChecked\": \"2020-03-07T21:00:00Z\", \"positive_diff\": 43.0, \"negative_diff\": 0.0, \"death_diff\": null, \"total_10\": 40.4, \"daily_positive\": 43.0}, {\"state\": \"NY\", \"date\": \"2020-03-06T00:00:00\", \"positive\": 33.0, \"negative\": 92.0, \"pending\": 236.0, \"hospitalized\": null, \"death\": null, \"total\": 361, \"dateChecked\": \"2020-03-06T21:00:00Z\", \"positive_diff\": 11.0, \"negative_diff\": 16.0, \"death_diff\": null, \"total_10\": 36.1, \"daily_positive\": 11.0}, {\"state\": \"NY\", \"date\": \"2020-03-05T00:00:00\", \"positive\": 22.0, \"negative\": 76.0, \"pending\": 24.0, \"hospitalized\": null, \"death\": null, \"total\": 122, \"dateChecked\": \"2020-03-05T21:00:00Z\", \"positive_diff\": 16.0, \"negative_diff\": 28.0, \"death_diff\": null, \"total_10\": 12.2, \"daily_positive\": 16.0}, {\"state\": \"NY\", \"date\": \"2020-03-04T00:00:00\", \"positive\": 6.0, \"negative\": 48.0, \"pending\": 24.0, \"hospitalized\": null, \"death\": null, \"total\": 78, \"dateChecked\": \"2020-03-04T21:00:00Z\", \"positive_diff\": null, \"negative_diff\": null, \"death_diff\": null, \"total_10\": 7.8, \"daily_positive\": null}]}}, {\"mode\": \"vega-lite\"});\n", "</script>" ], "text/plain": [ "alt.HConcatChart(...)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# produce the charts for a few states\n", "\n", "charts=[]\n", "for state in ['WA', 'CA', 'NY']: \n", " state_df = tdf_diff[tdf_diff['state'] == state].copy()\n", "\n", " state_df.loc[:,'daily_positive'] = state_df['positive'][::-1].diff()\n", " state_df.loc[:,'total_10'] = state_df['total']/10.\n", "\n", " base = alt.Chart(state_df, title=state).encode(alt.X('date', axis=alt.Axis(title='Date'))).properties(width=250, height=150)\n", " dailies = base.mark_bar(size=10).encode(alt.Y('daily_positive', axis=alt.Axis(title='Daily positive')))\n", "\n", " totals = base.mark_line(color='red').encode(alt.Y('total_10', axis=alt.Axis(title='Total/10'))) \n", " positives = totals.mark_line(color='orange').encode(alt.Y('positive', axis=alt.Axis(title='Positive')))\n", " cumulative = totals + positives\n", "\n", " charts.append(alt.layer(dailies, cumulative).resolve_scale(y='independent'))\n", "\n", "\n", "alt.hconcat(*charts)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Counts per 100k" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "pop_df = pd.read_csv('../../data/geodata/us_pop_fung_2019.csv').set_index('ST')" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Most recent test date 2020-03-23 00:00:00\n", "56 states/territories have data on this date.\n" ] } ], "source": [ "most_recent_test_date = data_df['date'].max()\n", "most_recent_df = data_df[data_df['date'] == most_recent_test_date].set_index('state')\n", "print(\"Most recent test date\", most_recent_test_date)\n", "print(len(most_recent_df), \"states/territories have data on this date.\")" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "most_recent_df['total/100k'] = (most_recent_df['total'] / pop_df['Population']) * 100000\n", "most_recent_df = most_recent_df.reset_index()" ] }, { "cell_type": "code", "execution_count": 13, "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>hospitalized</th>\n", " <th>death</th>\n", " <th>total</th>\n", " <th>dateChecked</th>\n", " <th>total/100k</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>AK</td>\n", " <td>2020-03-23</td>\n", " <td>22.0</td>\n", " <td>946.0</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>NaN</td>\n", " <td>968</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " <td>132.322687</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>AL</td>\n", " <td>2020-03-23</td>\n", " <td>167.0</td>\n", " <td>1665.0</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>1832</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " <td>37.363469</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>AR</td>\n", " <td>2020-03-23</td>\n", " <td>174.0</td>\n", " <td>906.0</td>\n", " <td>0.0</td>\n", " <td>13.0</td>\n", " <td>0.0</td>\n", " <td>1080</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " <td>35.787363</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>AS</td>\n", " <td>2020-03-23</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " <td>NaN</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>AZ</td>\n", " <td>2020-03-23</td>\n", " <td>265.0</td>\n", " <td>309.0</td>\n", " <td>6.0</td>\n", " <td>NaN</td>\n", " <td>2.0</td>\n", " <td>580</td>\n", " <td>2020-03-23T20:00:00Z</td>\n", " <td>7.968437</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " state date positive negative pending hospitalized death total \\\n", "0 AK 2020-03-23 22.0 946.0 NaN 0.0 NaN 968 \n", "1 AL 2020-03-23 167.0 1665.0 NaN NaN 0.0 1832 \n", "2 AR 2020-03-23 174.0 906.0 0.0 13.0 0.0 1080 \n", "3 AS 2020-03-23 NaN NaN NaN NaN 0.0 0 \n", "4 AZ 2020-03-23 265.0 309.0 6.0 NaN 2.0 580 \n", "\n", " dateChecked total/100k \n", "0 2020-03-23T20:00:00Z 132.322687 \n", "1 2020-03-23T20:00:00Z 37.363469 \n", "2 2020-03-23T20:00:00Z 35.787363 \n", "3 2020-03-23T20:00:00Z NaN \n", "4 2020-03-23T20:00:00Z 7.968437 " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "most_recent_df.head()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "<div id=\"altair-viz-96cbb7a23d4548ada8c97b5cf50d2497\"></div>\n", "<script type=\"text/javascript\">\n", " (function(spec, embedOpt){\n", " const outputDiv = document.getElementById(\"altair-viz-96cbb7a23d4548ada8c97b5cf50d2497\");\n", " const paths = {\n", " \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n", " \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n", " \"vega-lite\": \"https://cdn.jsdelivr.net/npm//vega-lite@4.0.2?noext\",\n", " \"vega-embed\": \"https://cdn.jsdelivr.net/npm//vega-embed@6?noext\",\n", " };\n", "\n", " function loadScript(lib) {\n", " return new Promise(function(resolve, reject) {\n", " var s = document.createElement('script');\n", " s.src = paths[lib];\n", " s.async = true;\n", " s.onload = () => resolve(paths[lib]);\n", " s.onerror = () => reject(`Error loading script: ${paths[lib]}`);\n", " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", " });\n", " }\n", "\n", " function showError(err) {\n", " outputDiv.innerHTML = `<div class=\"error\" style=\"color:red;\">${err}</div>`;\n", " throw err;\n", " }\n", "\n", " function displayChart(vegaEmbed) {\n", " vegaEmbed(outputDiv, spec, embedOpt)\n", " .catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));\n", " }\n", "\n", " if(typeof define === \"function\" && define.amd) {\n", " requirejs.config({paths});\n", " require([\"vega-embed\"], displayChart, err => showError(`Error loading script: ${err.message}`));\n", " } else if (typeof vegaEmbed === \"function\") {\n", " displayChart(vegaEmbed);\n", " } else {\n", " loadScript(\"vega\")\n", " .then(() => loadScript(\"vega-lite\"))\n", " .then(() => loadScript(\"vega-embed\"))\n", " .catch(showError)\n", " .then(() => displayChart(vegaEmbed));\n", " }\n", " })({\"config\": {\"view\": {\"continuousWidth\": 400, \"continuousHeight\": 300}}, \"data\": {\"name\": \"data-7e463e7da12798f05a867fe2891d0365\"}, \"mark\": \"bar\", \"encoding\": {\"x\": {\"type\": \"nominal\", \"field\": \"state\", \"sort\": \"y\"}, \"y\": {\"type\": \"quantitative\", \"field\": \"total/100k\"}}, \"title\": \"Tests per 100k\", \"$schema\": \"https://vega.github.io/schema/vega-lite/v4.0.2.json\", \"datasets\": {\"data-7e463e7da12798f05a867fe2891d0365\": [{\"state\": \"OH\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 442.0, \"negative\": 140.0, \"pending\": null, \"hospitalized\": 104.0, \"death\": 6.0, \"total\": 582, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 4.9789975276111935}, {\"state\": \"MD\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 288.0, \"negative\": 94.0, \"pending\": null, \"hospitalized\": null, \"death\": 3.0, \"total\": 382, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 6.3185613528999225}, {\"state\": \"AZ\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 265.0, \"negative\": 309.0, \"pending\": 6.0, \"hospitalized\": null, \"death\": 2.0, \"total\": 580, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 7.9684372946495925}, {\"state\": \"MO\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 183.0, \"negative\": 369.0, \"pending\": null, \"hospitalized\": null, \"death\": 3.0, \"total\": 552, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 8.993995530375264}, {\"state\": \"DE\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 68.0, \"negative\": 36.0, \"pending\": null, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 104, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 10.680205881507224}, {\"state\": \"KS\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 82.0, \"negative\": 417.0, \"pending\": null, \"hospitalized\": null, \"death\": 2.0, \"total\": 499, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 17.12826011888866}, {\"state\": \"NE\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 50.0, \"negative\": 356.0, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 406, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 20.988333381582375}, {\"state\": \"OK\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 81.0, \"negative\": 694.0, \"pending\": 102.0, \"hospitalized\": 15.0, \"death\": 2.0, \"total\": 877, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 22.163417422063493}, {\"state\": \"WV\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 16.0, \"negative\": 444.0, \"pending\": 4.0, \"hospitalized\": 1.0, \"death\": 0.0, \"total\": 464, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 25.963169230063336}, {\"state\": \"IN\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 259.0, \"negative\": 1701.0, \"pending\": null, \"hospitalized\": 1.0, \"death\": 7.0, \"total\": 1960, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 29.113729069122673}, {\"state\": \"MI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1328.0, \"negative\": 2069.0, \"pending\": null, \"hospitalized\": null, \"death\": 15.0, \"total\": 3397, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 34.01470552747476}, {\"state\": \"SC\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 299.0, \"negative\": 1466.0, \"pending\": null, \"hospitalized\": null, \"death\": 5.0, \"total\": 1765, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 34.28040477680446}, {\"state\": \"TX\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 352.0, \"negative\": 9703.0, \"pending\": null, \"hospitalized\": null, \"death\": 8.0, \"total\": 10055, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 34.67733917103605}, {\"state\": \"AR\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 174.0, \"negative\": 906.0, \"pending\": 0.0, \"hospitalized\": 13.0, \"death\": 0.0, \"total\": 1080, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 35.78736341570502}, {\"state\": \"NJ\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 2844.0, \"negative\": 359.0, \"pending\": 94.0, \"hospitalized\": null, \"death\": 27.0, \"total\": 3297, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 37.11922397516829}, {\"state\": \"AL\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 167.0, \"negative\": 1665.0, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 1832, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 37.36346884729008}, {\"state\": \"KY\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 104.0, \"negative\": 1762.0, \"pending\": null, \"hospitalized\": null, \"death\": 3.0, \"total\": 1866, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 41.76670942568984}, {\"state\": \"VA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 254.0, \"negative\": 3443.0, \"pending\": null, \"hospitalized\": 38.0, \"death\": 6.0, \"total\": 3697, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 43.31312483751721}, {\"state\": \"MS\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 249.0, \"negative\": 1143.0, \"pending\": null, \"hospitalized\": 33.0, \"death\": 1.0, \"total\": 1392, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 46.77185181252686}, {\"state\": \"GA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 772.0, \"negative\": 4297.0, \"pending\": null, \"hospitalized\": null, \"death\": 25.0, \"total\": 5069, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 47.7422817193965}, {\"state\": \"PA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 644.0, \"negative\": 6595.0, \"pending\": null, \"hospitalized\": null, \"death\": 6.0, \"total\": 7239, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 56.545900797133946}, {\"state\": \"TN\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 615.0, \"negative\": 3272.0, \"pending\": null, \"hospitalized\": null, \"death\": 2.0, \"total\": 3887, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 56.8842532035625}, {\"state\": \"FL\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1171.0, \"negative\": 11063.0, \"pending\": 860.0, \"hospitalized\": 217.0, \"death\": 14.0, \"total\": 13094, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 60.96545460073377}, {\"state\": \"CA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1733.0, \"negative\": 12567.0, \"pending\": 12100.0, \"hospitalized\": null, \"death\": 27.0, \"total\": 26400, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 66.81476767328428}, {\"state\": \"IA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 105.0, \"negative\": 2043.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 2148, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 68.08089836358623}, {\"state\": \"ID\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 47.0, \"negative\": 1309.0, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 1356, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 75.66689824308828}, {\"state\": \"IL\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1285.0, \"negative\": 8583.0, \"pending\": null, \"hospitalized\": null, \"death\": 12.0, \"total\": 9868, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 77.87357476088086}, {\"state\": \"NC\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 297.0, \"negative\": 8141.0, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 8438, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 80.45320765928267}, {\"state\": \"MN\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 235.0, \"negative\": 4511.0, \"pending\": null, \"hospitalized\": 17.0, \"death\": 1.0, \"total\": 4746, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 84.15442709737088}, {\"state\": \"OR\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 191.0, \"negative\": 3649.0, \"pending\": null, \"hospitalized\": 56.0, \"death\": 5.0, \"total\": 3840, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 91.04408359269438}, {\"state\": \"CO\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 591.0, \"negative\": 4845.0, \"pending\": null, \"hospitalized\": 58.0, \"death\": 6.0, \"total\": 5436, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 94.39571461515166}, {\"state\": \"WY\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 26.0, \"negative\": 592.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 618, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 106.78019693862213}, {\"state\": \"MT\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 34.0, \"negative\": 1146.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 1180, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 110.4064642049144}, {\"state\": \"RI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 106.0, \"negative\": 932.0, \"pending\": 216.0, \"hospitalized\": null, \"death\": null, \"total\": 1254, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 118.37324575852803}, {\"state\": \"SD\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 28.0, \"negative\": 762.0, \"pending\": 265.0, \"hospitalized\": null, \"death\": 1.0, \"total\": 1055, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 119.2549897757215}, {\"state\": \"NV\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 245.0, \"negative\": 3490.0, \"pending\": 0.0, \"hospitalized\": null, \"death\": 4.0, \"total\": 3735, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 121.26009202131321}, {\"state\": \"CT\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 415.0, \"negative\": 4085.0, \"pending\": null, \"hospitalized\": 54.0, \"death\": 10.0, \"total\": 4500, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 126.21704788422362}, {\"state\": \"LA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1172.0, \"negative\": 4776.0, \"pending\": null, \"hospitalized\": null, \"death\": 34.0, \"total\": 5948, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 127.94716221024206}, {\"state\": \"WI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 416.0, \"negative\": 7050.0, \"pending\": null, \"hospitalized\": null, \"death\": 5.0, \"total\": 7466, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 128.22816025050693}, {\"state\": \"MA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 777.0, \"negative\": 8145.0, \"pending\": null, \"hospitalized\": 79.0, \"death\": 9.0, \"total\": 8922, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 128.38328150948348}, {\"state\": \"AK\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 22.0, \"negative\": 946.0, \"pending\": null, \"hospitalized\": 0.0, \"death\": null, \"total\": 968, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 132.32268691604753}, {\"state\": \"UT\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 257.0, \"negative\": 4790.0, \"pending\": null, \"hospitalized\": null, \"death\": 1.0, \"total\": 5047, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 157.42564313069605}, {\"state\": \"NH\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 78.0, \"negative\": 1374.0, \"pending\": 889.0, \"hospitalized\": null, \"death\": null, \"total\": 2341, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 172.1689388406801}, {\"state\": \"DC\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 116.0, \"negative\": 1113.0, \"pending\": null, \"hospitalized\": null, \"death\": 2.0, \"total\": 1229, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 174.14123151432025}, {\"state\": \"ND\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 30.0, \"negative\": 1353.0, \"pending\": null, \"hospitalized\": 4.0, \"death\": 0.0, \"total\": 1383, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 181.48129679737343}, {\"state\": \"VT\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 75.0, \"negative\": 1106.0, \"pending\": null, \"hospitalized\": null, \"death\": 5.0, \"total\": 1181, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 189.26615693545878}, {\"state\": \"HI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 56.0, \"negative\": 2955.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 3011, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 212.6604664828459}, {\"state\": \"ME\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 107.0, \"negative\": 2791.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 2898, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 215.5909930873999}, {\"state\": \"NM\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 65.0, \"negative\": 5321.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 5386, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 256.8640551995418}, {\"state\": \"NY\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 20875.0, \"negative\": 57414.0, \"pending\": null, \"hospitalized\": 2635.0, \"death\": 114.0, \"total\": 78289, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 402.44045807346015}, {\"state\": \"WA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1996.0, \"negative\": 28879.0, \"pending\": null, \"hospitalized\": null, \"death\": 95.0, \"total\": 30875, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": 405.4554673322396}, {\"state\": \"AS\", \"date\": \"2020-03-23T00:00:00\", \"positive\": null, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 0, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": null}, {\"state\": \"GU\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 29.0, \"negative\": 161.0, \"pending\": null, \"hospitalized\": null, \"death\": 1.0, \"total\": 190, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": null}, {\"state\": \"MP\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 0.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 0, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": null}, {\"state\": \"PR\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 31.0, \"negative\": 189.0, \"pending\": 35.0, \"hospitalized\": null, \"death\": 2.0, \"total\": 255, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": null}, {\"state\": \"VI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 17.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 17, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"total/100k\": null}]}}, {\"mode\": \"vega-lite\"});\n", "</script>" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "chart = alt.Chart(most_recent_df.sort_values('total/100k'), title=\"Tests per 100k\")\n", "chart.mark_bar().encode(alt.X('state', sort='y'), alt.Y('total/100k'))" ] } ], "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.3" } }, "nbformat": 4, "nbformat_minor": 4 }