Extracting COVID AdministrativeDivision data from Wolfram Resource

Wolfram makes the COVID-19 case data available in a form that is conveniently formatted for processing in Mathematica.

It can be accessed using:

data2 = ResourceData[ResourceUpdate["Epidemic Data for Novel Coronavirus COVID-19"]]


[Syntax provided by swish in his answer to COVID-19 Wolfram Data Repository Retrieval ]

Suppose I want to pull out the data for New York state. Since NY state is in the third row, I can get it using:

data2[[3]]


However, NY state might not always be in the third row. So how would I instead extract that row by how it is named in the AdministrativeDivision column ("New York, United States")?

• data2[Select[#AdministrativeDivision == {"New York", "United States"} &]?
– kglr
Apr 5, 2020 at 5:44
• ... or Query[Select[#a == {"New York", "United States"} &]] @data2?
– kglr
Apr 5, 2020 at 5:47
• Not knowing the full administrative division names, I tend to use StringMatchQ on the county names. Not very pretty, and somewhat embarrassing (to me), but it works. Apr 5, 2020 at 15:03
• @kglr Yeah, something along those lines was what I had been trying, and none of my attempts worked. Unfortunately, none of yours do either ;). The first one (after adding the missing bracket at the end) gives an empty output, and the second one gives a Failure message. What's needed is the construction provided by LouisB: data2[Select[#AdministrativeDivision == Entity["AdministrativeDivision", {"NewYork", "UnitedStates"}] &]]. I've found Wolfram's Entity syntax to be among the most cumbersome and non-intuitive within the Wolfram Language. Apr 5, 2020 at 18:49
• You could also try something like data[Select[! MissingQ[#AdministrativeDivision] && ContainsAny[ CanonicalName@#AdministrativeDivision, {"NewYork"}] &]]
– chuy
Apr 6, 2020 at 19:58

Here's the code I've been using for various states:

res = ResourceData["Epidemic Data for Novel Coronavirus COVID-19"];

cal = Entity[
{"California", "UnitedStates"}];
{"NewYork", "UnitedStates"}];

state = ny;

data = res[Select[#AdministrativeDivision == state &]][[1, -3 ;;]] //
Normal;

ts = data[[#]] & /@ {"ConfirmedCases", "RecoveredCases", "Deaths"};

DateListPlot[ts, PlotRange -> {All, All},
Frame -> True, PlotLabel -> state["Name"],
GridLines -> Automatic]


To sum the data over many administrative divisions I've been using this:

china = Entity["Country", "China"];
With[{data =
res[Select[(#Country == china &&