Function Repository Resource:

OWIDCOVID19Data

Source Notebook

Generate testing and vaccination datasets from the OWID COVID-19 data site

Contributed by: Mads Bahrami and Carlos Munoz

ResourceFunction["OWIDCOVID19Data"][]

returns vaccination and testing datasets for countries on the Our World in Data (OWID) site.

ResourceFunction["OWIDCOVID19Data"][type]

returns either testing or vaccination data, depending on the value of type.

ResourceFunction["OWIDCOVID19Data"]["Vaccination","USA"]

returns vaccination data for US states and US territories.

ResourceFunction["OWIDCOVID19Data"]["CountryMetadata"]

returns the vaccination metadata for countries.

Details and Options

The argument type, which specifies the data, can be either "Testing" or "Vaccination".
By default, an Association will be returned with keys "Testing" and "Vaccination" and the corresponding datasets for values.
ResourceFunction["OWIDCOVID19Data"]["Vaccination"] generates a dataset from the OWID vaccination data for countries. The dataset will be an Association of associations, where the keys are regions, and for associations, the keys (column tags) are "TotalVaccinations", "PeopleVaccinated", "PeopleFullyVaccinated", "DailyVaccinationsRaw", "DailyVaccinations", "TotalVaccinationsPerHundred", "PeopleVaccinatedPerHundred", "PeopleFullyVaccinatedPerHundred" and "DailyVaccinationsPerMillion".
ResourceFunction["OWIDCOVID19Data"]["Testing"] generates a dataset from the OWID testing data for countries. The dataset will be an Association of associations, where the keys are regions, and for associations, the keys (column tags) are "DataUnit" and "CumulativeTests".
ResourceFunction["OWIDCOVID19Data"]["CountryMetadata"] returns the vaccination metadata for countries.
ResourceFunction["OWIDCOVID19Data"] takes the option "RegionInterpretation" (default True). If True, the function returns the corresponding geo-regions as built-in entities in Wolfram Language.
More information about the exact meaning of data in each column is given here.

Examples

Basic Examples (2) 

Generate the vaccination dataset:

In[1]:=
vaccineDT = ResourceFunction["OWIDCOVID19Data"][
    "Vaccination"]; // AbsoluteTiming
Out[1]=

The column names:

In[2]:=
vaccineDT[1] // Keys // Normal
Out[2]=

Visualize the top 20 countries in terms of people vaccinated:

In[3]:=
vaccineDT // Length
Out[3]=
In[4]:=
vaccineDT[
  KeySelect[MatchQ[#, Entity["Country", _] | _String] &]] // Length
Out[4]=
In[5]:=
With[{asso = Normal[vaccineDT[
      KeySelect[MatchQ[#, Entity["Country", _] | _String] &]][
     TakeLargestBy[#PeopleVaccinated["LastValue"] &, 20], #PeopleVaccinated["LastValue"] &]]}, BarChart[asso, BarOrigin -> Left, ChartLabels -> Keys[asso], Frame -> True, GridLines -> Automatic, PlotLabel -> "People Vaccinated", ImageSize -> 700]]
Out[5]=

Plot the total number of vaccinations for the 10 countries with the highest total number of vaccinations:

In[6]:=
With[{asso = Normal[vaccineDT[
      KeySelect[MatchQ[#, Entity["Country", _] | _String] &]][
     TakeLargestBy[#TotalVaccinations["LastValue"] &, 10], "TotalVaccinations"]]},
 DateListPlot[
  KeyValueMap[
   Callout[Tooltip[DeleteMissing[#2], CommonName[#1]], #1] &, asso], PlotRange -> All, Frame -> True, GridLines -> Automatic, PlotLabel -> "Total Vaccinations of Time", ImageSize -> 700]]
Out[6]=

Visualize the fully vaccinated people in the continental US:

In[7]:=
ResourceFunction["OWIDCOVID19Data"]["Vaccination", "USA"][
  KeySelect[
   MemberQ[EntityList@
      EntityClass["AdministrativeDivision", "ContinentalUSStates"], #] &]][
 GeoRegionValuePlot[#, GeoProjection -> "Mercator", PlotLabel -> "Fully Vaccinated People per US States"] &, #PeopleFullyVaccinated["LastValue"] &]
Out[7]=

Applications (3) 

Generate the vaccination dataset:

In[8]:=
vaccineDT = ResourceFunction["OWIDCOVID19Data"][
    "Vaccination"]; // AbsoluteTiming
Out[8]=

Visualize the top 20 countries in terms of percentage of fully-vaccinated people:

In[9]:=
With[{asso = Normal[vaccineDT[
      KeySelect[MatchQ[#, Entity["Country", _] | _String] &]][
     TakeLargestBy[#PeopleFullyVaccinatedPerHundred["LastValue"] &, 20], #PeopleFullyVaccinatedPerHundred["LastValue"] &]]}, BarChart[asso, BarOrigin -> Left, ChartLabels -> Keys[asso], Frame -> True, GridLines -> Automatic, AspectRatio -> 1/2, PlotLabel -> "People Fully Vaccinated (%)", ImageSize -> 700]]
Out[9]=

Generate the testing dataset:

In[10]:=
testingDT = ResourceFunction["OWIDCOVID19Data"]["Testing"]; // AbsoluteTiming
Out[10]=

Columns of the dataset:

In[11]:=
testingDT[1] // Keys // Normal
Out[11]=

Visualize the testing units done so far:

In[12]:=
With[{tests = Counts@testingDT[Values, "DataUnit"]}, PieChart[tests, ChartLegends -> Normal@Keys[tests]]]
Out[12]=

Visualize the cumulative tests performed across countries:

In[13]:=
With[{asso = Normal[testingDT[
     TakeLargestBy[#CumulativeTests["LastValue"] &, 20], #CumulativeTests["LastValue"] &]]}, BarChart[asso, BarOrigin -> Left, ChartLabels -> Keys[asso], Frame -> True, GridLines -> Automatic, AspectRatio -> 1/2, PlotLabel -> "Cumulative Tests Performed", ImageSize -> 700]]
Out[13]=

Generate the "CountryMetadata" dataset:

In[14]:=
metadataDT = ResourceFunction["OWIDCOVID19Data"][
    "CountryMetadata"]; // AbsoluteTiming
Out[14]=

Show which vaccines are being applied worldwide:

In[15]:=
vaccineNames = Union @@ Normal[metadataDT[All, "Vaccines"]];
vaccinesByCountry = metadataDT[
   KeySelect[! MissingQ[#] && Head[#] == Entity && EntityTypeName[#] == "Country" &],
   <|"Vaccines" -> "Vaccines"|>
   ];
Manipulate[
 GeoListPlot[
  Keys@Normal@vaccinesByCountry[Select[MemberQ[#Vaccines, vacc] &]],
  GeoLabels -> (Tooltip[#1, #2] &), PlotLabel -> vacc, GeoRange -> "World"],
 {{vacc, "Pfizer/BioNTech", "Vaccine: "}, vaccineNames}
 , SaveDefinitions -> True]
Out[15]=

Options (2) 

"RegionInterpretation" can be set as True or False in order to interpret geo-regions as entities or not:

In[16]:=
ds = ResourceFunction["OWIDCOVID19Data"]["Testing", "RegionInterpretation" -> False];
ds[;; 2]
Out[16]=

Return the head of the keys:

In[17]:=
Tally[Head /@ Normal[Keys[ds]]]
Out[17]=

Note that for "RegionInterpretation"True, the heads are Entity objects:

In[18]:=
Tally[Head /@ Normal[Keys[ResourceFunction["OWIDCOVID19Data"]["Testing"]]]]
Out[18]=

Publisher

Wolfram Summer Camp

Version History

  • 2.2.0 – 04 May 2021
  • 2.1.0 – 18 March 2021
  • 2.0.0 – 03 February 2021
  • 1.0.0 – 20 January 2021

Source Metadata

Related Resources

Author Notes

Mads Bahrami (Wolfram Research) and Carlos Munoz (Wolfram Research)

License Information