3
$\begingroup$

I'm doing a project using one of the datasets in the Wolfram Data Repository, and I ran into a weird wall that I have not been able to fix.

I imported the dataset like this:

COVIDData = ResourceData[ResourceObject["Coronavirus COVID-19 Pandemic Government Measures"]]

Then, using the select function, I should be able to select various countries based on their respective values in the dataset. For example, I can select all the rows with the UNCode "AFG", and get an implementation date:

Normal[COVIDData[Select[#UNCode == "AFG" &]][All,"ImplementationDate"]]

Filtering by UNCode works fine, however some of the others columns I filter by mysteriously give me a white box, even though the code should be correct. In particular, trying to filter by Country, Region, and Continent all give me a blank white box as an output:

Normal[COVIDData[Select[#Country== "Afghanistan" &]][All,"ImplementationDate"]]

Normal[COVIDData[Select[#Region== "Asia" &]][All,"ImplementationDate"]]

Normal[COVIDData[Select[#Continent== "Asia" &]][All,"ImplementationDate"]]

The 3 code lines above all give a blank white box. I've tried doing a bunch of different things, all of them ending up in that blank white box. Is this a problem with the dataset, or is there another approach to make this work?

Thanks

$\endgroup$
4
  • 2
    $\begingroup$ The values of Country, Region and Continent are not strings. Instead, they are entities, which you can see if you try Normal@COVIDData[2, {"Country", "Region", "Continent"}] // InputForm $\endgroup$
    – creidhne
    Aug 12, 2021 at 21:08
  • 2
    $\begingroup$ So, for example, Normal[COVIDData[Select[#Country == Entity["Country", "Afghanistan"] &]][All, "ImplementationDate"]] gets the ImplementationDate data for Afghanistan. $\endgroup$
    – creidhne
    Aug 12, 2021 at 21:11
  • $\begingroup$ Got it, thank you! $\endgroup$
    – Arcee
    Aug 12, 2021 at 21:24
  • $\begingroup$ The blank white box means an empty Dataset object $\endgroup$
    – b3m2a1
    Aug 13, 2021 at 2:12

1 Answer 1

2
$\begingroup$

The Country attribute is a "Country" Enitiy.

Normal[COVIDData[
   Select[#Country == Entity["Country", "Afghanistan"] &]][All,"ImplementationDate"]]

The Region and Continent attributes are "Country" EntityClasses.

Normal[COVIDData[Select[#Region == EntityClass["Country", "Asia"] &]][All, "ImplementationDate"]]

Normal[COVIDData[
   Select[#Continent == EntityClass["Country", "Asia"] &]][All, "ImplementationDate"]]

See the Enter Free-Form Input workflow for keyboard shortcuts to enter these. For example, for Asian "Country" EntityClass you can type:

Ctrl+= Asian Continent Enter (not numpad Enter)

instead of the input form.

Hope this helps.

$\endgroup$
1
  • $\begingroup$ That worked, thank you so much! $\endgroup$
    – Arcee
    Aug 12, 2021 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.