Function Repository Resource:

CaliforniaCOVID19Data

Source Notebook

Generate datasets from California COVID-19 data released by the State of California

Contributed by: Mads Bahrami (Wolfram Research)

ResourceFunction["CaliforniaCOVID19Data"][prop]

returns the COVID-19 dataset for prop.

Details and Options

The prop can be "Testing", "Hospitals", "Cases", "Age", "Sex" or "Ethnicity" as a String, or any combination of them as a List. If prop is given as a String, the corresponding dataset is returned; with prop as a List, an Association is returned with keys as elements of prop, and values the corresponding datasets.
ResourceFunction["CaliforniaCOVID19Data"] takes the option "Dictionary" (default False). If True, the function returns the corresponding data dictionary.
The resulting dataset contains TimeSeries for requested properties. More details are given in the "Dictionary".
The data is scraped from the California government COVID-19 data source.

Examples

Basic Examples (4) 

Get the testing dataset:

In[1]:=
testing = ResourceFunction["CaliforniaCOVID19Data"][
    "Testing"]; // AbsoluteTiming
Out[1]=

Visualize testing:

In[2]:=
Column[Normal@
  testing[Entity[
     "AdministrativeDivision", {"California", "UnitedStates"}]][
   KeyValueMap[
    DateListPlot[MovingAverage[#2, 7], PlotRange -> All, PlotTheme -> "Business", AspectRatio -> 1/4, ImageSize -> Medium, PlotLabel -> #1 <> ", CA", Filling -> Bottom] &]], Frame -> All]
Out[2]=

Get COVID-19 confirmed cases dataset:

In[3]:=
cases = ResourceFunction["CaliforniaCOVID19Data"][
    "Cases"]; // AbsoluteTiming
Out[3]=

Visualize daily cases:

In[4]:=
Column[Normal@
  cases[Entity[
     "AdministrativeDivision", {"California", "UnitedStates"}]][
   KeyValueMap[
    DateListPlot[MovingAverage[#2, 7], PlotRange -> All, PlotTheme -> "Business", AspectRatio -> 1/4, ImageSize -> Medium, PlotLabel -> #1 <> ", Daily Data of CA", Filling -> Bottom] &]], Frame -> All]
Out[4]=

Visualize the ICU COVID-19 patients and ICU available beds:

In[5]:=
DateListPlot[{(hospitals = ResourceFunction["CaliforniaCOVID19Data"]["Hospitals"])[Total, "ICUCovidConfirmedPatients"], hospitals[Total, "ICUAvailableBeds"]}, PlotTheme -> "Business", AspectRatio -> 1/4, ImageSize -> Large, PlotLabel -> "ICU Available Beds and ICU COVID19-Patients, California", PlotLegends -> {"ICU COVID19-Patients", "Available ICU Beds"}, Filling -> Bottom]
Out[5]=

Visualize COVID-19 death across age groups:

In[6]:=
With[{dt = ResourceFunction["CaliforniaCOVID19Data"][
     "Age"][;; -3, #TotalCases["LastValue"] &]}, PieChart[dt, PlotLabel -> "Last Value of Total Cases", ChartLegends -> Normal@Keys[dt]]]
Out[6]=

Options (1) 

Dictionary (1) 

Use "Dictionary" to get the corresponding data dictionary:

In[7]:=
ResourceFunction["CaliforniaCOVID19Data"]["Hospitals", "Dictionary" -> True]
Out[7]=

Publisher

Wolfram Summer Camp

Version History

  • 3.0.0 – 14 April 2021
  • 2.0.0 – 22 March 2021
  • 1.0.0 – 08 February 2021

Related Resources

Author Notes

Mads Bahrami (Wolfram Research Inc)

License Information