5
$\begingroup$

I'm struggling to get certain rows from a Dataset. Here's the set:

plateData = ResourceData["Large Global Plate Boundaries"]

I'd like to do something like this, which obviously isn't working. "Get the rows from the dataset that include "America" in the name.

Select[plateData, StringContainsQ[#Name, "American" | "american"] &]

I'd like to think their is a way do do this simply.

$\endgroup$

1 Answer 1

5
$\begingroup$

At its heart, the issue is that some of the entries in that data set have Missing["NotAvailable"] for the "Name" parameter. Dataset only applies selection criteria until it hits an error, at which point it simply throws a Failure object (I believe this is a fail-safe to keep from crashing the kernel / FE with compounded errors in big data).

So simply add a "not missing" check to the Select:

plateData[
  Select[
   ! MissingQ@#["Name"] && 
     StringContainsQ[#["Name"], "American" | "american"] & 
   ]
  ] // Length

441
$\endgroup$

Your Answer

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

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