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"} &]
? $\endgroup$Query[Select[#a == {"New York", "United States"} &]] @data2
? $\endgroup$StringMatchQ
on the county names. Not very pretty, and somewhat embarrassing (to me), but it works. $\endgroup$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. $\endgroup$data[Select[! MissingQ[#AdministrativeDivision] && ContainsAny[ CanonicalName@#AdministrativeDivision, {"NewYork"}] &]]
$\endgroup$