1
$\begingroup$

I struggle to answer the following question:

Use ResourceData["New Orleans Slave Sales 1856-1861"] to answer the following question: How many rows in which the NotaryFirstName contains the letter "e" (or "E") have no value (i.e. missing value) in the Price field?

Here is the beginning of my code where I could only find all the names in the data:

slavelist = ResourceData["New Orleans Slave Sales 1856-1861"]
namelist = slavelist[All, "NotaryFirstName"]
$\endgroup$
  • $\begingroup$ Length@slavelist[ Select[ (! MissingQ@#NotaryFirstName && StringContainsQ[#NotaryFirstName, "e"]) && MissingQ@#Price &]] Please read the documentation for Dataset, which has examples extremely similar to this question. I am voting to close this question as a) it's an obvious homework question and b) the answer is easily found in the documentation. $\endgroup$ – Carl Lange Feb 25 '19 at 21:43
1
$\begingroup$

I am making this post to record the answer given by @CarlLange in a comment to the question.

Evaluating

slavelist = ResourceData["New Orleans Slave Sales 1856-1861"];

assigns a dataset to slavelist, so any valid dataset query can be used to extract information from slavelist. In this case, the appropriated query is

query = 
  slavelist[
    Select[
      ! MissingQ @ #NotaryFirstName && 
      StringContainsQ[#NotaryFirstName, "e", IgnoreCase -> True] && 
      MissingQ @ #Price &]];

and then

Length @ query  

1997

Note: I have modified Lange's code a little to make it conform more exactly to the criteria given in the question.

$\endgroup$