I am using three different sources to do the analysis.

  1. US COVID-19 vaccination data
  2. US state population data
  3. US COVID-19 daily cases data
!pip install hvplot
!apt-get install libgeos++ libproj-dev
!pip install geoviews
!pip install geopandas

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libgeos-c1' for regex 'libgeos+'
Note, selecting 'libgeos-c1v5' for regex 'libgeos+'
Note, selecting 'libgeos-dev' for regex 'libgeos+'
Note, selecting 'libgeos-doc' for regex 'libgeos+'
Note, selecting 'libgeos-ruby1.8' for regex 'libgeos+'
Note, selecting 'libgeos++-dev' for regex 'libgeos+'
Note, selecting 'libgeos-3.6.2' for regex 'libgeos+'
Note, selecting 'ruby-geos' instead of 'libgeos-ruby1.8'
libgeos-3.6.2 is already the newest version (3.6.2-1build2).
libgeos-3.6.2 set to manually installed.
libgeos-c1v5 is already the newest version (3.6.2-1build2).
libgeos-c1v5 set to manually installed.
The following additional packages will be installed:
  fonts-lato javascript-common libjs-jquery libruby2.5 rake ruby
  ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert
  ruby-test-unit ruby2.5 rubygems-integration
Suggested packages:
  apache2 | lighttpd | httpd libgdal-doc proj-bin ri ruby-dev bundler
The following NEW packages will be installed:
  fonts-lato javascript-common libgeos++-dev libgeos-dev libgeos-doc
  libjs-jquery libproj-dev libruby2.5 rake ruby ruby-did-you-mean ruby-geos
  ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.5
  rubygems-integration
0 upgraded, 18 newly installed, 0 to remove and 13 not upgraded.
Need to get 8,128 kB of archives.
After this operation, 53.2 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 fonts-lato all 2.0-2 [2,698 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 javascript-common all 11 [6,066 B]
Get:3 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libgeos-dev amd64 3.6.2-1build2 [73.1 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libgeos++-dev amd64 3.6.2-1build2 [811 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 libjs-jquery all 3.2.1-1 [152 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libgeos-doc all 3.6.2-1build2 [852 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 rubygems-integration all 1.11 [4,994 B]
Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ruby2.5 amd64 2.5.1-1ubuntu1.7 [48.6 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 ruby amd64 1:2.5.1 [5,712 B]
Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 rake all 12.3.1-1ubuntu0.1 [44.9 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic/main amd64 ruby-did-you-mean all 1.2.0-2 [9,700 B]
Get:12 http://archive.ubuntu.com/ubuntu bionic/main amd64 ruby-minitest all 5.10.3-1 [38.6 kB]
Get:13 http://archive.ubuntu.com/ubuntu bionic/main amd64 ruby-net-telnet all 0.1.1-2 [12.6 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic/main amd64 ruby-power-assert all 0.3.0-1 [7,952 B]
Get:15 http://archive.ubuntu.com/ubuntu bionic/main amd64 ruby-test-unit all 3.2.5-1 [61.1 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libruby2.5 amd64 2.5.1-1ubuntu1.7 [3,068 kB]
Get:17 http://archive.ubuntu.com/ubuntu bionic/universe amd64 ruby-geos amd64 3.6.2-1build2 [34.3 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libproj-dev amd64 4.9.3-2 [199 kB]
Fetched 8,128 kB in 2s (5,144 kB/s)
Selecting previously unselected package fonts-lato.
(Reading database ... 146374 files and directories currently installed.)
Preparing to unpack .../00-fonts-lato_2.0-2_all.deb ...
Unpacking fonts-lato (2.0-2) ...
Selecting previously unselected package javascript-common.
Preparing to unpack .../01-javascript-common_11_all.deb ...
Unpacking javascript-common (11) ...
Selecting previously unselected package libgeos-dev.
Preparing to unpack .../02-libgeos-dev_3.6.2-1build2_amd64.deb ...
Unpacking libgeos-dev (3.6.2-1build2) ...
Selecting previously unselected package libgeos++-dev.
Preparing to unpack .../03-libgeos++-dev_3.6.2-1build2_amd64.deb ...
Unpacking libgeos++-dev (3.6.2-1build2) ...
Selecting previously unselected package libjs-jquery.
Preparing to unpack .../04-libjs-jquery_3.2.1-1_all.deb ...
Unpacking libjs-jquery (3.2.1-1) ...
Selecting previously unselected package libgeos-doc.
Preparing to unpack .../05-libgeos-doc_3.6.2-1build2_all.deb ...
Unpacking libgeos-doc (3.6.2-1build2) ...
Selecting previously unselected package rubygems-integration.
Preparing to unpack .../06-rubygems-integration_1.11_all.deb ...
Unpacking rubygems-integration (1.11) ...
Selecting previously unselected package ruby2.5.
Preparing to unpack .../07-ruby2.5_2.5.1-1ubuntu1.7_amd64.deb ...
Unpacking ruby2.5 (2.5.1-1ubuntu1.7) ...
Selecting previously unselected package ruby.
Preparing to unpack .../08-ruby_1%3a2.5.1_amd64.deb ...
Unpacking ruby (1:2.5.1) ...
Selecting previously unselected package rake.
Preparing to unpack .../09-rake_12.3.1-1ubuntu0.1_all.deb ...
Unpacking rake (12.3.1-1ubuntu0.1) ...
Selecting previously unselected package ruby-did-you-mean.
Preparing to unpack .../10-ruby-did-you-mean_1.2.0-2_all.deb ...
Unpacking ruby-did-you-mean (1.2.0-2) ...
Selecting previously unselected package ruby-minitest.
Preparing to unpack .../11-ruby-minitest_5.10.3-1_all.deb ...
Unpacking ruby-minitest (5.10.3-1) ...
Selecting previously unselected package ruby-net-telnet.
Preparing to unpack .../12-ruby-net-telnet_0.1.1-2_all.deb ...
Unpacking ruby-net-telnet (0.1.1-2) ...
Selecting previously unselected package ruby-power-assert.
Preparing to unpack .../13-ruby-power-assert_0.3.0-1_all.deb ...
Unpacking ruby-power-assert (0.3.0-1) ...
Selecting previously unselected package ruby-test-unit.
Preparing to unpack .../14-ruby-test-unit_3.2.5-1_all.deb ...
Unpacking ruby-test-unit (3.2.5-1) ...
Selecting previously unselected package libruby2.5:amd64.
Preparing to unpack .../15-libruby2.5_2.5.1-1ubuntu1.7_amd64.deb ...
Unpacking libruby2.5:amd64 (2.5.1-1ubuntu1.7) ...
Selecting previously unselected package ruby-geos:amd64.
Preparing to unpack .../16-ruby-geos_3.6.2-1build2_amd64.deb ...
Unpacking ruby-geos:amd64 (3.6.2-1build2) ...
Selecting previously unselected package libproj-dev:amd64.
Preparing to unpack .../17-libproj-dev_4.9.3-2_amd64.deb ...
Unpacking libproj-dev:amd64 (4.9.3-2) ...
Setting up libjs-jquery (3.2.1-1) ...
Setting up libproj-dev:amd64 (4.9.3-2) ...
Setting up libgeos-dev (3.6.2-1build2) ...
Setting up fonts-lato (2.0-2) ...
Setting up ruby-did-you-mean (1.2.0-2) ...
Setting up ruby-net-telnet (0.1.1-2) ...
Setting up rubygems-integration (1.11) ...
Setting up libgeos-doc (3.6.2-1build2) ...
Setting up javascript-common (11) ...
Setting up ruby-minitest (5.10.3-1) ...
Setting up ruby-power-assert (0.3.0-1) ...
Setting up libgeos++-dev (3.6.2-1build2) ...
Setting up ruby-test-unit (3.2.5-1) ...
Setting up libruby2.5:amd64 (2.5.1-1ubuntu1.7) ...
Setting up ruby-geos:amd64 (3.6.2-1build2) ...
Setting up ruby2.5 (2.5.1-1ubuntu1.7) ...
Setting up ruby (1:2.5.1) ...
Setting up rake (12.3.1-1ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.3) ...
/sbin/ldconfig.real: /usr/local/lib/python3.6/dist-packages/ideep4py/lib/libmkldnn.so.0 is not a symbolic link

Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for fontconfig (2.12.6-0ubuntu2) ...
Collecting geoviews
  Downloading https://files.pythonhosted.org/packages/fe/75/e12fe3397a22bdbb7bdbc5a1ad2571677653fb34b06948b05835627b690d/geoviews-1.8.1-py2.py3-none-any.whl (500kB)
     |████████████████████████████████| 501kB 5.3MB/s 
Collecting cartopy>=0.17.0
  Downloading https://files.pythonhosted.org/packages/46/c1/04e50c9986842f00f7db0e7a65caa896840050d7328f74e5b7437aa01179/Cartopy-0.18.0.tar.gz (14.4MB)
     |████████████████████████████████| 14.4MB 304kB/s 
Requirement already satisfied: bokeh>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from geoviews) (2.1.1)
Requirement already satisfied: holoviews>=1.13.0 in /usr/local/lib/python3.6/dist-packages (from geoviews) (1.13.5)
Requirement already satisfied: numpy>=1.0 in /usr/local/lib/python3.6/dist-packages (from geoviews) (1.19.5)
Requirement already satisfied: param>=1.9.2 in /usr/local/lib/python3.6/dist-packages (from geoviews) (1.10.1)
Requirement already satisfied: shapely>=1.5.6 in /usr/local/lib/python3.6/dist-packages (from cartopy>=0.17.0->geoviews) (1.7.1)
Collecting pyshp>=1.1.4
  Downloading https://files.pythonhosted.org/packages/38/85/fbf87e7aa55103e0d06af756bdbc15cf821fa580414c23142d60a35d4f85/pyshp-2.1.3.tar.gz (219kB)
     |████████████████████████████████| 225kB 34.0MB/s 
Requirement already satisfied: six>=1.3.0 in /usr/local/lib/python3.6/dist-packages (from cartopy>=0.17.0->geoviews) (1.15.0)
Requirement already satisfied: setuptools>=0.7.2 in /usr/local/lib/python3.6/dist-packages (from cartopy>=0.17.0->geoviews) (51.3.3)
Requirement already satisfied: PyYAML>=3.10 in /usr/local/lib/python3.6/dist-packages (from bokeh>=2.0.0->geoviews) (3.13)
Requirement already satisfied: tornado>=5.1 in /usr/local/lib/python3.6/dist-packages (from bokeh>=2.0.0->geoviews) (5.1.1)
Requirement already satisfied: packaging>=16.8 in /usr/local/lib/python3.6/dist-packages (from bokeh>=2.0.0->geoviews) (20.8)
Requirement already satisfied: typing-extensions>=3.7.4 in /usr/local/lib/python3.6/dist-packages (from bokeh>=2.0.0->geoviews) (3.7.4.3)
Requirement already satisfied: pillow>=4.0 in /usr/local/lib/python3.6/dist-packages (from bokeh>=2.0.0->geoviews) (7.0.0)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from bokeh>=2.0.0->geoviews) (2.8.1)
Requirement already satisfied: Jinja2>=2.7 in /usr/local/lib/python3.6/dist-packages (from bokeh>=2.0.0->geoviews) (2.11.2)
Requirement already satisfied: panel>=0.8.0 in /usr/local/lib/python3.6/dist-packages (from holoviews>=1.13.0->geoviews) (0.9.7)
Requirement already satisfied: pyviz-comms>=0.7.3 in /usr/local/lib/python3.6/dist-packages (from holoviews>=1.13.0->geoviews) (2.0.1)
Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (from holoviews>=1.13.0->geoviews) (1.1.5)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.6/dist-packages (from packaging>=16.8->bokeh>=2.0.0->geoviews) (2.4.7)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.6/dist-packages (from Jinja2>=2.7->bokeh>=2.0.0->geoviews) (1.1.1)
Requirement already satisfied: pyct>=0.4.4 in /usr/local/lib/python3.6/dist-packages (from panel>=0.8.0->holoviews>=1.13.0->geoviews) (0.4.8)
Requirement already satisfied: markdown in /usr/local/lib/python3.6/dist-packages (from panel>=0.8.0->holoviews>=1.13.0->geoviews) (3.3.3)
Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from panel>=0.8.0->holoviews>=1.13.0->geoviews) (4.41.1)
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas->holoviews>=1.13.0->geoviews) (2018.9)
Requirement already satisfied: importlib-metadata; python_version < "3.8" in /usr/local/lib/python3.6/dist-packages (from markdown->panel>=0.8.0->holoviews>=1.13.0->geoviews) (3.3.0)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata; python_version < "3.8"->markdown->panel>=0.8.0->holoviews>=1.13.0->geoviews) (3.4.0)
Building wheels for collected packages: cartopy, pyshp
  Building wheel for cartopy (setup.py) ... done
  Created wheel for cartopy: filename=Cartopy-0.18.0-cp36-cp36m-linux_x86_64.whl size=15132421 sha256=733c47b8b4f8bccd41de2a600f0f8b907b4562ee5d30a849bb518d2889a9d69c
  Stored in directory: /root/.cache/pip/wheels/8d/f8/da/2c05136f2162370d2baec85bfbbf91d7729ab9e248da878acd
  Building wheel for pyshp (setup.py) ... done
  Created wheel for pyshp: filename=pyshp-2.1.3-cp36-none-any.whl size=37264 sha256=05a834c7eaa2682379c6412a6df8871d48921f5572780f22ac0a263f6972147e
  Stored in directory: /root/.cache/pip/wheels/76/2b/d4/53e6b9a0fb0a9f9f29664cf82605af8bc81d5ab44d987896dd
Successfully built cartopy pyshp
Installing collected packages: pyshp, cartopy, geoviews
Successfully installed cartopy-0.18.0 geoviews-1.8.1 pyshp-2.1.3
Collecting geopandas
  Downloading https://files.pythonhosted.org/packages/2a/9f/e8a440a993e024c0d3d4e5c7d3346367c50c9a1a3d735caf5ee3bde0aab1/geopandas-0.8.2-py2.py3-none-any.whl (962kB)
     |████████████████████████████████| 972kB 6.3MB/s 
Collecting pyproj>=2.2.0
  Downloading https://files.pythonhosted.org/packages/e4/ab/280e80a67cfc109d15428c0ec56391fc03a65857b7727cf4e6e6f99a4204/pyproj-3.0.0.post1-cp36-cp36m-manylinux2010_x86_64.whl (6.4MB)
     |████████████████████████████████| 6.5MB 15.4MB/s 
Requirement already satisfied: pandas>=0.23.0 in /usr/local/lib/python3.6/dist-packages (from geopandas) (1.1.5)
Requirement already satisfied: shapely in /usr/local/lib/python3.6/dist-packages (from geopandas) (1.7.1)
Collecting fiona
  Downloading https://files.pythonhosted.org/packages/37/94/4910fd55246c1d963727b03885ead6ef1cd3748a465f7b0239ab25dfc9a3/Fiona-1.8.18-cp36-cp36m-manylinux1_x86_64.whl (14.8MB)
     |████████████████████████████████| 14.8MB 334kB/s 
Requirement already satisfied: certifi in /usr/local/lib/python3.6/dist-packages (from pyproj>=2.2.0->geopandas) (2020.12.5)
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas>=0.23.0->geopandas) (2018.9)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.6/dist-packages (from pandas>=0.23.0->geopandas) (2.8.1)
Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.6/dist-packages (from pandas>=0.23.0->geopandas) (1.19.5)
Requirement already satisfied: attrs>=17 in /usr/local/lib/python3.6/dist-packages (from fiona->geopandas) (20.3.0)
Collecting click-plugins>=1.0
  Downloading https://files.pythonhosted.org/packages/e9/da/824b92d9942f4e472702488857914bdd50f73021efea15b4cad9aca8ecef/click_plugins-1.1.1-py2.py3-none-any.whl
Requirement already satisfied: click<8,>=4.0 in /usr/local/lib/python3.6/dist-packages (from fiona->geopandas) (7.1.2)
Collecting munch
  Downloading https://files.pythonhosted.org/packages/cc/ab/85d8da5c9a45e072301beb37ad7f833cd344e04c817d97e0cc75681d248f/munch-2.5.0-py2.py3-none-any.whl
Collecting cligj>=0.5
  Downloading https://files.pythonhosted.org/packages/42/1e/947eadf10d6804bf276eb8a038bd5307996dceaaa41cfd21b7a15ec62f5d/cligj-0.7.1-py3-none-any.whl
Requirement already satisfied: six>=1.7 in /usr/local/lib/python3.6/dist-packages (from fiona->geopandas) (1.15.0)
Installing collected packages: pyproj, click-plugins, munch, cligj, fiona, geopandas
Successfully installed click-plugins-1.1.1 cligj-0.7.1 fiona-1.8.18 geopandas-0.8.2 munch-2.5.0 pyproj-3.0.0.post1
import pandas as pd
import numpy as np
import geopandas as gpd
from datetime import datetime,timedelta
import hvplot.pandas
import holoviews as hv
#import matplotlib.pyplot as plt
import panel as pn
from panel.interact import interact, interactive
from panel import widgets
from datetime import datetime

State populations

us_states_population_data_source = "https://raw.githubusercontent.com/COVID19Tracking/associated-data/master/us_census_data/us_census_2018_population_estimates_states.csv"
us_state_populations = pd.read_csv(us_states_population_data_source)
us_state_populations.head()
state state_name geo_id population pop_density
0 AL Alabama 1 4887871 96.509389
1 AK Alaska 2 737438 1.291523
2 AZ Arizona 4 7171646 63.135855
3 AR Arkansas 5 3013825 57.919684
4 CA California 6 39557045 253.906502

State abbreviations

state_abbrev_source = "https://raw.githubusercontent.com/jasonong/List-of-US-States/master/states.csv"
state_codes = pd.read_csv(state_abbrev_source)
state_codes.head()
State Abbreviation
0 Alabama AL
1 Alaska AK
2 Arizona AZ
3 Arkansas AR
4 California CA

Reading US vaccine data

Source for this data is wor world in data's github page. I am using the

us_vaccination_data_path = "https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/vaccinations/us_state_vaccinations.csv"
us_vaccination_data = pd.read_csv(us_vaccination_data_path)
us_vaccination_data.head()
date location total_distributed total_vaccinations distributed_per_hundred total_vaccinations_per_hundred people_vaccinated people_vaccinated_per_hundred people_fully_vaccinated people_fully_vaccinated_per_hundred daily_vaccinations_raw daily_vaccinations daily_vaccinations_per_million share_doses_used
0 2021-01-12 Alabama 377025.0 78134.0 7.69 1.59 70861.0 1.44 7270.0 0.15 NaN NaN NaN 0.207
1 2021-01-13 Alabama 378975.0 84040.0 7.73 1.71 74792.0 1.52 9245.0 0.19 5906.0 5906.0 1205.0 0.222
2 2021-01-14 Alabama 435350.0 92300.0 8.88 1.88 80480.0 1.64 NaN NaN 8260.0 7083.0 1445.0 0.212
3 2021-01-15 Alabama 444650.0 100567.0 9.07 2.05 86956.0 1.77 13488.0 0.27 8267.0 7478.0 1525.0 0.226
4 2021-01-16 Alabama NaN NaN NaN NaN NaN NaN NaN NaN 7557.0 7498.0 1529.0 NaN
us_vaccination_data_w_state_code = us_vaccination_data.merge(state_codes,
                                                             how='inner',
                                                             left_on="location",
                                                             right_on="State")
us_vaccination_data_w_state_code[us_vaccination_data_w_state_code["people_vaccinated"].isna()]
date location total_distributed total_vaccinations distributed_per_hundred total_vaccinations_per_hundred people_vaccinated people_vaccinated_per_hundred people_fully_vaccinated people_fully_vaccinated_per_hundred daily_vaccinations_raw daily_vaccinations daily_vaccinations_per_million share_doses_used State Abbreviation
4 2021-01-16 Alabama NaN NaN NaN NaN NaN NaN NaN NaN 7557.00 7498.0 1529.0 NaN Alabama AL
5 2021-01-17 Alabama NaN NaN NaN NaN NaN NaN NaN NaN 7557.00 7509.0 1531.0 NaN Alabama AL
6 2021-01-18 Alabama NaN NaN NaN NaN NaN NaN NaN NaN 7557.00 7517.0 1533.0 NaN Alabama AL
18 2021-01-16 Alaska NaN NaN NaN NaN NaN NaN NaN NaN 4323.00 4381.0 5989.0 NaN Alaska AK
19 2021-01-17 Alaska NaN NaN NaN NaN NaN NaN NaN NaN 4323.00 4369.0 5972.0 NaN Alaska AK
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
677 2021-01-17 Wisconsin NaN NaN NaN NaN NaN NaN NaN NaN 10923.75 10880.0 1869.0 NaN Wisconsin WI
678 2021-01-18 Wisconsin NaN NaN NaN NaN NaN NaN NaN NaN 10923.75 10887.0 1870.0 NaN Wisconsin WI
690 2021-01-16 Wyoming NaN NaN NaN NaN NaN NaN NaN NaN 1328.00 1902.0 3286.0 NaN Wyoming WY
691 2021-01-17 Wyoming NaN NaN NaN NaN NaN NaN NaN NaN 1328.00 1787.0 3088.0 NaN Wyoming WY
692 2021-01-18 Wyoming NaN NaN NaN NaN NaN NaN NaN NaN 1328.00 1710.0 2955.0 NaN Wyoming WY

160 rows × 16 columns

us_vaccination_data_w_state_code["date"] = pd.to_datetime(us_vaccination_data_w_state_code["date"])
hv.extension('bokeh')
us_vaccination_data_w_state_code.hvplot.line(x='date',
                                y='people_vaccinated',
                                by="State",
                                rot=90,
                                height=500,
                                width=900)

</img> </img>
us_vaccination_data.shape
(910, 14)
us_vaccination_data["location"].unique(), us_vaccination_data["location"].nunique()
(array(['Alabama', 'Alaska', 'American Samoa', 'Arizona', 'Arkansas',
        'Bureau of Prisons', 'California', 'Colorado', 'Connecticut',
        'Delaware', 'Dept of Defense', 'District of Columbia',
        'Federated States of Micronesia', 'Florida', 'Georgia', 'Guam',
        'Hawaii', 'Idaho', 'Illinois', 'Indian Health Svc', 'Indiana',
        'Iowa', 'Kansas', 'Kentucky', 'Long Term Care', 'Louisiana',
        'Maine', 'Marshall Islands', 'Maryland', 'Massachusetts',
        'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana',
        'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico',
        'New York State', 'North Carolina', 'North Dakota',
        'Northern Mariana Islands', 'Ohio', 'Oklahoma', 'Oregon',
        'Pennsylvania', 'Puerto Rico', 'Republic of Palau', 'Rhode Island',
        'South Carolina', 'South Dakota', 'Tennessee', 'Texas',
        'United States', 'Utah', 'Vermont', 'Veterans Health',
        'Virgin Islands', 'Virginia', 'Washington', 'West Virginia',
        'Wisconsin', 'Wyoming'], dtype=object), 65)
us_vaccination_data_w_state_code_latest_date = us_vaccination_data_w_state_code[us_vaccination_data_w_state_code["date"]==us_vaccination_data_w_state_code["date"].max()]
hv.extension('bokeh')
us_vaccination_data_w_state_code_latest_date.hvplot.bar(x="Abbreviation",
                                                        y="people_vaccinated",
                                                        rot=90)

</img> </img>
hv.extension('bokeh')
us_vaccination_data_w_state_code_latest_date.sort_values(by="total_vaccinations_per_hundred",ascending=False).hvplot.bar(x="State",
                                                        y="total_vaccinations_per_hundred",
                                                        height=700,
                                                        width = 1500,
                                                        rot=90)

</img> </img>

Alaska and West Virginia are killing it in vaccinating their populations

Reading Covid Case counts data

def get_us_states_latest_case_report_path(del):

    date_str_for_jhu_daily_report = (datetime.now()-timedelta(days=del)).strftime("%m-%d-%Y")

    us_states_covid_daily_report_path = ("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports_us/{}.csv".format(date_str_for_jhu_daily_report))
    
  return us_states_covid_daily_report_path
try:
    us_states_latest_case_data = pd.read_csv(get_us_states_latest_case_report_path(del=1))
except:
    us_states_latest_case_data = pd.read_csv(get_us_states_latest_case_report_path(del=2))
us_states_latest_case_data.head()
Province_State Country_Region Last_Update Lat Long_ Confirmed Deaths Recovered Active FIPS Incident_Rate Total_Test_Results People_Hospitalized Case_Fatality_Ratio UID ISO3 Testing_Rate Hospitalization_Rate
0 Alabama US 2021-01-25 05:30:45 32.3182 -86.9023 441170 6660 233211.0 201299.0 1.0 8997.620934 2086555.0 NaN 1.509622 84000001.0 USA 42555.094291 NaN
1 Alaska US 2021-01-25 05:30:45 61.3707 -152.4044 53315 259 NaN 53056.0 2.0 7288.000055 1453470.0 NaN 0.485792 84000002.0 USA 198684.974950 NaN
2 American Samoa US 2021-01-25 05:30:45 -14.2710 -170.1320 0 0 NaN 0.0 60.0 0.000000 2140.0 NaN NaN 16.0 ASM 3846.084722 NaN
3 Arizona US 2021-01-25 05:30:45 33.7298 -111.4312 722574 12238 97960.0 612376.0 4.0 9927.216569 3350246.0 NaN 1.693667 84000004.0 USA 46027.974436 NaN
4 Arkansas US 2021-01-25 05:30:45 34.9697 -92.3731 284066 4606 260034.0 19426.0 5.0 9413.003628 2347388.0 NaN 1.621454 84000005.0 USA 77784.640752 NaN
us_states_latest_case_data.shape
(58, 18)
hv.extension('bokeh')
us_states_latest_case_data.sort_values(by="Confirmed",
                                       ascending=False).hvplot.bar(x="Province_State",
                                                                   y="Confirmed",
                                                                   width=1000,
                                                                   height = 600,
                                                                   rot=90)

</img> </img>
us_states_latest_case_data["Recovered"].isna().sum()
14
hv.extension('bokeh')
us_states_latest_case_data.sort_values(by="Recovered",
                                       ascending=False).hvplot.bar(x="Province_State",
                                                                   y="Recovered",
                                                                   width=1000,
                                                                   height = 600,
                                                                   rot=90)

</img> </img>
hv.extension('bokeh')
us_states_latest_case_data.sort_values(by="Case_Fatality_Ratio",
                                       ascending=False).hvplot.bar(x="Province_State",
                                                                   y="Case_Fatality_Ratio",
                                                                   width=1000,
                                                                   height = 600,
                                                                   rot=90)

</img> </img>
us_states_latest_case_data_gdf = (gpd.GeoDataFrame(us_states_latest_case_data,
                                                   geometry=gpd.points_from_xy(us_states_latest_case_data.Long_,us_states_latest_case_data.Lat))
)
us_states_latest_case_data_gdf.head()
Province_State Country_Region Last_Update Lat Long_ Confirmed Deaths Recovered Active FIPS Incident_Rate Total_Test_Results People_Hospitalized Case_Fatality_Ratio UID ISO3 Testing_Rate Hospitalization_Rate geometry
0 Alabama US 2021-01-25 05:30:45 32.3182 -86.9023 441170 6660 233211.0 201299.0 1.0 8997.620934 2086555.0 NaN 1.509622 84000001.0 USA 42555.094291 NaN POINT (-86.90230 32.31820)
1 Alaska US 2021-01-25 05:30:45 61.3707 -152.4044 53315 259 NaN 53056.0 2.0 7288.000055 1453470.0 NaN 0.485792 84000002.0 USA 198684.974950 NaN POINT (-152.40440 61.37070)
2 American Samoa US 2021-01-25 05:30:45 -14.2710 -170.1320 0 0 NaN 0.0 60.0 0.000000 2140.0 NaN NaN 16.0 ASM 3846.084722 NaN POINT (-170.13200 -14.27100)
3 Arizona US 2021-01-25 05:30:45 33.7298 -111.4312 722574 12238 97960.0 612376.0 4.0 9927.216569 3350246.0 NaN 1.693667 84000004.0 USA 46027.974436 NaN POINT (-111.43120 33.72980)
4 Arkansas US 2021-01-25 05:30:45 34.9697 -92.3731 284066 4606 260034.0 19426.0 5.0 9413.003628 2347388.0 NaN 1.621454 84000005.0 USA 77784.640752 NaN POINT (-92.37310 34.96970)
us_states_latest_case_data_gdf = us_states_latest_case_data_gdf.merge(state_codes,
                                                                      how="inner",
                                                                      left_on="Province_State",
                                                                      right_on="State")
us_states_latest_case_data_gdf.shape
(51, 21)
us_states_latest_case_data_gdf.head()
Province_State Country_Region Last_Update Lat Long_ Confirmed Deaths Recovered Active FIPS Incident_Rate Total_Test_Results People_Hospitalized Case_Fatality_Ratio UID ISO3 Testing_Rate Hospitalization_Rate geometry State Abbreviation
0 Alabama US 2021-01-25 05:30:45 32.3182 -86.9023 441170 6660 233211.0 201299.0 1.0 8997.620934 2086555.0 NaN 1.509622 84000001.0 USA 42555.094291 NaN POINT (-86.90230 32.31820) Alabama AL
1 Alaska US 2021-01-25 05:30:45 61.3707 -152.4044 53315 259 NaN 53056.0 2.0 7288.000055 1453470.0 NaN 0.485792 84000002.0 USA 198684.974950 NaN POINT (-152.40440 61.37070) Alaska AK
2 Arizona US 2021-01-25 05:30:45 33.7298 -111.4312 722574 12238 97960.0 612376.0 4.0 9927.216569 3350246.0 NaN 1.693667 84000004.0 USA 46027.974436 NaN POINT (-111.43120 33.72980) Arizona AZ
3 Arkansas US 2021-01-25 05:30:45 34.9697 -92.3731 284066 4606 260034.0 19426.0 5.0 9413.003628 2347388.0 NaN 1.621454 84000005.0 USA 77784.640752 NaN POINT (-92.37310 34.96970) Arkansas AR
4 California US 2021-01-25 08:30:35 36.1162 -119.6816 3187475 37121 NaN 3131407.0 6.0 8019.108416 40285715.0 NaN 1.171553 84000006.0 USA 101957.601829 NaN POINT (-119.68160 36.11620) California CA

Plotting the COVID metrics on USA map

import plotly.graph_objects as go
geo_df = us_states_latest_case_data_gdf.copy()

fig = go.Figure(data=go.Choropleth(locations=geo_df["Abbreviation"],
                                   locationmode="USA-states",
                                   z=geo_df["Confirmed"],
                                   colorscale = "Reds",
                                   colorbar_title="Cumulative positive cases"))
#fig.update_geos(fitbounds="locations", visible=False)

fig.update_layout(
    title_text = 'Total COVID-19 cases by State',
    geo_scope='usa', # limite map scope to USA
)

fig.show()
fig = go.Figure(data=go.Choropleth(locations=geo_df["Abbreviation"],
                                   locationmode="USA-states",
                                   z=geo_df["Recovered"],
                                   colorscale = "Greens",
                                   colorbar_title="Cumulative positive cases"))
#fig.update_geos(fitbounds="locations", visible=False)

fig.update_layout(
    title_text = 'Total COVID-19 cases by State',
    geo_scope='usa', # limite map scope to USA
)

fig.show()

joining COVID vaccinations cases and population data

us_states_latest_case_data_gdf_w_population =  us_states_latest_case_data_gdf.merge(us_state_populations,
                                                                                    how="left",
                                                                                    left_on="Abbreviation",
                                                                                    right_on="state")
us_states_latest_case_data_gdf_w_population.head()
Province_State Country_Region Last_Update Lat Long_ Confirmed Deaths Recovered Active FIPS Incident_Rate Total_Test_Results People_Hospitalized Case_Fatality_Ratio UID ISO3 Testing_Rate Hospitalization_Rate geometry State Abbreviation state state_name geo_id population pop_density
0 Alabama US 2021-01-25 05:30:45 32.3182 -86.9023 441170 6660 233211.0 201299.0 1.0 8997.620934 2086555.0 NaN 1.509622 84000001.0 USA 42555.094291 NaN POINT (-86.90230 32.31820) Alabama AL AL Alabama 1 4887871 96.509389
1 Alaska US 2021-01-25 05:30:45 61.3707 -152.4044 53315 259 NaN 53056.0 2.0 7288.000055 1453470.0 NaN 0.485792 84000002.0 USA 198684.974950 NaN POINT (-152.40440 61.37070) Alaska AK AK Alaska 2 737438 1.291523
2 Arizona US 2021-01-25 05:30:45 33.7298 -111.4312 722574 12238 97960.0 612376.0 4.0 9927.216569 3350246.0 NaN 1.693667 84000004.0 USA 46027.974436 NaN POINT (-111.43120 33.72980) Arizona AZ AZ Arizona 4 7171646 63.135855
3 Arkansas US 2021-01-25 05:30:45 34.9697 -92.3731 284066 4606 260034.0 19426.0 5.0 9413.003628 2347388.0 NaN 1.621454 84000005.0 USA 77784.640752 NaN POINT (-92.37310 34.96970) Arkansas AR AR Arkansas 5 3013825 57.919684
4 California US 2021-01-25 08:30:35 36.1162 -119.6816 3187475 37121 NaN 3131407.0 6.0 8019.108416 40285715.0 NaN 1.171553 84000006.0 USA 101957.601829 NaN POINT (-119.68160 36.11620) California CA CA California 6 39557045 253.906502
us_vaccination_data_w_state_code_latest_date.query("Abbreviation=='NY'")
date location total_distributed total_vaccinations distributed_per_hundred total_vaccinations_per_hundred people_vaccinated people_vaccinated_per_hundred people_fully_vaccinated people_fully_vaccinated_per_hundred daily_vaccinations_raw daily_vaccinations daily_vaccinations_per_million share_doses_used State Abbreviation
us_states_latest_case_data_gdf_w_population_and_vaccination = us_states_latest_case_data_gdf_w_population.merge(us_vaccination_data_w_state_code_latest_date,
                                                                                                                how="inner",
                                                                                                                on="Abbreviation")
us_states_latest_case_data_gdf_w_population_and_vaccination.shape
(50, 41)
us_states_latest_case_data_gdf_w_population_and_vaccination.head()
Province_State Country_Region Last_Update Lat Long_ Confirmed Deaths Recovered Active FIPS Incident_Rate Total_Test_Results People_Hospitalized Case_Fatality_Ratio UID ISO3 Testing_Rate Hospitalization_Rate geometry State_x Abbreviation state state_name geo_id population pop_density date location total_distributed total_vaccinations distributed_per_hundred total_vaccinations_per_hundred people_vaccinated people_vaccinated_per_hundred people_fully_vaccinated people_fully_vaccinated_per_hundred daily_vaccinations_raw daily_vaccinations daily_vaccinations_per_million share_doses_used State_y
0 Alabama US 2021-01-25 05:30:45 32.3182 -86.9023 441170 6660 233211.0 201299.0 1.0 8997.620934 2086555.0 NaN 1.509622 84000001.0 USA 42555.094291 NaN POINT (-86.90230 32.31820) Alabama AL AL Alabama 1 4887871 96.509389 2021-01-25 Alabama 521225.0 250612.0 10.63 5.11 220464.0 4.50 29978.0 0.61 6875.0 18196.0 3711.0 0.481 Alabama
1 Alaska US 2021-01-25 05:30:45 61.3707 -152.4044 53315 259 NaN 53056.0 2.0 7288.000055 1453470.0 NaN 0.485792 84000002.0 USA 198684.974950 NaN POINT (-152.40440 61.37070) Alaska AK AK Alaska 2 737438 1.291523 2021-01-25 Alaska 155700.0 97031.0 21.28 13.26 80226.0 10.97 16673.0 2.28 2774.0 5003.0 6839.0 0.623 Alaska
2 Arizona US 2021-01-25 05:30:45 33.7298 -111.4312 722574 12238 97960.0 612376.0 4.0 9927.216569 3350246.0 NaN 1.693667 84000004.0 USA 46027.974436 NaN POINT (-111.43120 33.72980) Arizona AZ AZ Arizona 4 7171646 63.135855 2021-01-25 Arizona 829500.0 413662.0 11.40 5.68 350648.0 4.82 62711.0 0.86 23039.0 23526.0 3232.0 0.499 Arizona
3 Arkansas US 2021-01-25 05:30:45 34.9697 -92.3731 284066 4606 260034.0 19426.0 5.0 9413.003628 2347388.0 NaN 1.621454 84000005.0 USA 77784.640752 NaN POINT (-92.37310 34.96970) Arkansas AR AR Arkansas 5 3013825 57.919684 2021-01-25 Arkansas 368650.0 221095.0 12.22 7.33 185546.0 6.15 33159.0 1.10 6855.0 12108.0 4012.0 0.600 Arkansas
4 California US 2021-01-25 08:30:35 36.1162 -119.6816 3187475 37121 NaN 3131407.0 6.0 8019.108416 40285715.0 NaN 1.171553 84000006.0 USA 101957.601829 NaN POINT (-119.68160 36.11620) California CA CA California 6 39557045 253.906502 2021-01-25 California 4906525.0 2330633.0 12.42 5.90 1954048.0 4.94 371482.0 0.94 130725.0 138153.0 3496.0 0.475 California
def impute_recovered_data(row):
  """
  In case of recovered data is not available,
  we can use the CFR data to calculate the expected recoveries 
  """

  if pd.isnull(row["Recovered"]):
    return row["Confirmed"]*(1-(row["Case_Fatality_Ratio"]/100))
  else:
    return row["Recovered"]
us_states_latest_case_data_gdf_w_population_and_vaccination["Recovered_"] = us_states_latest_case_data_gdf_w_population_and_vaccination.apply(impute_recovered_data,axis=1)
us_states_latest_case_data_gdf_w_population_and_vaccination["Recovered_"].isna().sum()
0
us_states_latest_case_data_gdf_w_population_and_vaccination["expected_immune_population"] = (us_states_latest_case_data_gdf_w_population_and_vaccination["Recovered_"] + 
                                                                                             us_states_latest_case_data_gdf_w_population_and_vaccination["people_vaccinated"])
us_states_latest_case_data_gdf_w_population_and_vaccination["expected_immune_population_p_100"] = (us_states_latest_case_data_gdf_w_population_and_vaccination["expected_immune_population"]/
                                                                                                   us_states_latest_case_data_gdf_w_population_and_vaccination["population"])*100 
def plot_choropeth_usa(geo_df,col,colorscale,title):

  

  fig = go.Figure(data=go.Choropleth(locations=geo_df["Abbreviation"],
                                   locationmode="USA-states",
                                   z=geo_df[col],
                                   colorscale = colorscale,
                                   colorbar_title=col))
  #fig.update_geos(fitbounds="locations", visible=False)

  fig.update_layout(
    title_text = title,
    geo_scope='usa', # limite map scope to USA
    )

  fig.show()
us_states_latest_case_data_gdf_w_population_and_vaccination.query("state=='NY'")
Province_State Country_Region Last_Update Lat Long_ Confirmed Deaths Recovered Active FIPS Incident_Rate Total_Test_Results People_Hospitalized Case_Fatality_Ratio UID ISO3 Testing_Rate Hospitalization_Rate geometry State_x Abbreviation state state_name geo_id population pop_density date location total_distributed total_vaccinations distributed_per_hundred total_vaccinations_per_hundred people_vaccinated people_vaccinated_per_hundred people_fully_vaccinated people_fully_vaccinated_per_hundred daily_vaccinations_raw daily_vaccinations daily_vaccinations_per_million share_doses_used State_y Recovered_ expected_immune_population expected_immune_population_p_100
plot_choropeth_usa(geo_df=us_states_latest_case_data_gdf_w_population_and_vaccination,
                   col="expected_immune_population_p_100",
                   colorscale="Greens",
                   title="The percentage of population immune to COVID-19 in each state as of {}".format(datetime.now()))
us_states_latest_case_data_gdf_w_population_and_vaccination.head()
Province_State Country_Region Last_Update Lat Long_ Confirmed Deaths Recovered Active FIPS Incident_Rate Total_Test_Results People_Hospitalized Case_Fatality_Ratio UID ISO3 Testing_Rate Hospitalization_Rate geometry State_x Abbreviation state state_name geo_id population pop_density date location total_distributed total_vaccinations distributed_per_hundred total_vaccinations_per_hundred people_vaccinated people_vaccinated_per_hundred people_fully_vaccinated people_fully_vaccinated_per_hundred daily_vaccinations_raw daily_vaccinations daily_vaccinations_per_million share_doses_used State_y Recovered_ expected_immune_population expected_immune_population_p_100
0 Alabama US 2021-01-25 05:30:45 32.3182 -86.9023 441170 6660 233211.0 201299.0 1.0 8997.620934 2086555.0 NaN 1.509622 84000001.0 USA 42555.094291 NaN POINT (-86.90230 32.31820) Alabama AL AL Alabama 1 4887871 96.509389 2021-01-25 Alabama 521225.0 250612.0 10.63 5.11 220464.0 4.50 29978.0 0.61 6875.0 18196.0 3711.0 0.481 Alabama 2.332110e+05 4.536750e+05 9.281648
1 Alaska US 2021-01-25 05:30:45 61.3707 -152.4044 53315 259 NaN 53056.0 2.0 7288.000055 1453470.0 NaN 0.485792 84000002.0 USA 198684.974950 NaN POINT (-152.40440 61.37070) Alaska AK AK Alaska 2 737438 1.291523 2021-01-25 Alaska 155700.0 97031.0 21.28 13.26 80226.0 10.97 16673.0 2.28 2774.0 5003.0 6839.0 0.623 Alaska 5.305600e+04 1.332820e+05 18.073655
2 Arizona US 2021-01-25 05:30:45 33.7298 -111.4312 722574 12238 97960.0 612376.0 4.0 9927.216569 3350246.0 NaN 1.693667 84000004.0 USA 46027.974436 NaN POINT (-111.43120 33.72980) Arizona AZ AZ Arizona 4 7171646 63.135855 2021-01-25 Arizona 829500.0 413662.0 11.40 5.68 350648.0 4.82 62711.0 0.86 23039.0 23526.0 3232.0 0.499 Arizona 9.796000e+04 4.486080e+05 6.255300
3 Arkansas US 2021-01-25 05:30:45 34.9697 -92.3731 284066 4606 260034.0 19426.0 5.0 9413.003628 2347388.0 NaN 1.621454 84000005.0 USA 77784.640752 NaN POINT (-92.37310 34.96970) Arkansas AR AR Arkansas 5 3013825 57.919684 2021-01-25 Arkansas 368650.0 221095.0 12.22 7.33 185546.0 6.15 33159.0 1.10 6855.0 12108.0 4012.0 0.600 Arkansas 2.600340e+05 4.455800e+05 14.784535
4 California US 2021-01-25 08:30:35 36.1162 -119.6816 3187475 37121 NaN 3131407.0 6.0 8019.108416 40285715.0 NaN 1.171553 84000006.0 USA 101957.601829 NaN POINT (-119.68160 36.11620) California CA CA California 6 39557045 253.906502 2021-01-25 California 4906525.0 2330633.0 12.42 5.90 1954048.0 4.94 371482.0 0.94 130725.0 138153.0 3496.0 0.475 California 3.150132e+06 5.104180e+06 12.903340

How to take into account the undetected positive cases?