Function Repository Resource:

COVID19EpidemicData

Source Notebook

Access COVID-19 epidemic data

Contributed by: Carlos Muñoz

ResourceFunction["COVID19EpidemicData"][location]

returns an association of the most recent COVID-19 data for location.

ResourceFunction["COVID19EpidemicData"][location,property]

returns the most recent value for property.

ResourceFunction["COVID19EpidemicData"][location,dateInterval]

returns data for the specified dateInterval.

ResourceFunction["COVID19EpidemicData"][location,dateInterval,property]

returns a time series for the given dateInterval and property.

ResourceFunction["COVID19EpidemicData"][location,date,property]

returns the nearest available value for property on or before the given date.

Details and Options

The location argument should be a member of EntityClass["Country",All], a member of EntityClass["AdministrativeDivision", "AllUSStatesPlusDC"], or the string standard name of such an Entity.
The dateInterval argument should be either a DateInterval or All. When All is used, all available data is returned. The date argument should be a DateObject.
The input property can be any of the following: "ConfirmedCases", "Deaths", "RecoveredCases", "DailyConfirmedCases", "DailyDeaths" or "DailyRecoveredCases".
Data returned by ResourceFunction["COVID19EpidemicData"] is retrieved from the COVID-19 Epidemic Data dataset in the Wolfram Data Repository.

Examples

Basic Examples (10) 

Get an Association with the most recent values of all properties for a given country:

In[1]:=
ResourceFunction["COVID19EpidemicData"][Entity["Country", "Spain"]]
Out[1]=

Get an Association with the most recent values of all properties for a given US state:

In[2]:=
ResourceFunction["COVID19EpidemicData"][
 Entity["AdministrativeDivision", {"NewHampshire", "UnitedStates"}]]
Out[2]=

Get an Association with a time series for each property for a given country:

In[3]:=
ResourceFunction["COVID19EpidemicData"][
 Entity["Country", "Sweden"], All]
Out[3]=

Get an Association with a time series for each property for a given US state:

In[4]:=
ResourceFunction["COVID19EpidemicData"][
 Entity["AdministrativeDivision", {"Montana", "UnitedStates"}], All]
Out[4]=

Get data corresponding to a given date interval for a given country:

In[5]:=
ResourceFunction["COVID19EpidemicData"][Entity["Country", "Jamaica"], DateInterval[{DateObject[{2020, 6, 1}], DateObject[{2020, 7, 1}]}]]
Out[5]=

Get data corresponding to a given date interval for a given US state:

In[6]:=
ResourceFunction["COVID19EpidemicData"][
 Entity["AdministrativeDivision", {"Illinois", "UnitedStates"}], DateInterval[{DateObject[{2020, 6, 1}], DateObject[{2020, 7, 1}]}]]
Out[6]=

Get and plot the time series for a given country and property:

In[7]:=
ts = ResourceFunction["COVID19EpidemicData"][
   Entity["Country", "Cambodia"], All, "DailyConfirmedCases"];
In[8]:=
DateListPlot[ts, PlotLabel -> "DailyConfirmedCases", PlotRange -> All]
Out[8]=

Get the most recent value for a given property:

In[9]:=
ResourceFunction["COVID19EpidemicData"][
 Entity["Country", "Greenland"], "DailyDeaths"]
Out[9]=

Get and plot the time series for a given property and date interval:

In[10]:=
DateListPlot@
 ResourceFunction["COVID19EpidemicData"][
  Entity["AdministrativeDivision", {"Kansas", "UnitedStates"}], DateInterval[{DateObject[{2020, 6, 1}], DateObject[{2020, 6, 30}]}],
   "Deaths"]
Out[10]=

Get the nearest available value for a property at or before the given date:

In[11]:=
ResourceFunction["COVID19EpidemicData"][
 Entity["AdministrativeDivision", {"Nevada", "UnitedStates"}], DateObject[{2020, 7, 4}], "DailyConfirmedCases"]
Out[11]=

Scope (2) 

COVID19EpidemicData can accept a standard name instead of a geographic entity to specify location:

In[12]:=
ResourceFunction["COVID19EpidemicData"]["Anguilla"]
Out[12]=
In[13]:=
ResourceFunction["COVID19EpidemicData"]["NorthDakota"]
Out[13]=

Entity["Country","World"] or its string standard name can be used in place of a geographic entity to get the most recent values for a given property:

In[14]:=
ResourceFunction["COVID19EpidemicData"][
 Entity["Country", "World"], All]
Out[14]=

Possible Issues (4) 

The correct standard name should be used when the geographic entity is given as a String:

In[15]:=
ResourceFunction[
 "COVID19EpidemicData"]["United States", "ConfirmedCases"]
Out[15]=
In[16]:=
ResourceFunction[
 "COVID19EpidemicData"]["UnitedStates", "ConfirmedCases"]
Out[16]=

Only countries or US states are accepted entities:

In[17]:=
ResourceFunction["COVID19EpidemicData"][ Entity["Species", "Genus:Delphinus"]]
Out[17]=

This function returns Missing["NotAvailable"] if the geographic entity is not part of the COVID-19 Epidemic Data dataset in the Wolfram Data Repository:

In[18]:=
ResourceFunction["COVID19EpidemicData"][
 Entity["Country", "Samoa"], "ConfirmedCases"]
Out[18]=

DateObject and DateInterval inputs must be contained within the start and end dates of the overall dataset:

In[19]:=
ResourceFunction["COVID19EpidemicData"][Entity["Country", "Mexico"], DateInterval[{DateObject[{2010, 6, 1}], DateObject[{2010, 6, 30}]}], "Deaths"]
Out[19]=

Neat Examples (2) 

Show the distribution of confirmed cases over the United States:

In[20]:=
GeoRegionValuePlot[# -> ResourceFunction["COVID19EpidemicData"][#, "ConfirmedCases"] & /@ EntityList[
   EntityClass["AdministrativeDivision", "AllUSStatesPlusDC"]]]
Out[20]=

Show the distribution of deaths over all countries:

In[21]:=
GeoRegionValuePlot[# -> ResourceFunction["COVID19EpidemicData"][#, "Deaths"] & /@ EntityList[EntityClass["Country", "Countries"]]]
Out[21]=

Version History

  • 1.1.0 – 25 September 2020
  • 1.0.0 – 26 August 2020

Related Resources

License Information