For a given keyless dataset, I can query to return the rows whose columns contain a specific value. For example:

ds = Dataset[{{"a", "b"}, {"c", "d"}, {"e", "f"}, {"g", "h"}}]
Query[Select[#[[2]] == "f" &]]@ds

returns the dataset {e,f}.

But, in this simple example, I would like to test:


How can I perform this operation without writing out every value of interest. For example, I want check if #[[2]] contains any value from the list"check":


ds[GroupBy[#[[2]]&][check] changes the dataset structure. I just want to remove rows from the original dataset.

  • 4
    $\begingroup$ You could do Query[Select[MemberQ[check, #[[2]]] &]]@ds, for example. $\endgroup$ Commented Jun 18, 2015 at 14:04
  • $\begingroup$ Slick--I had been trying MemberQ but not implementing it correctly. Please add as an answer so that I can give credit. $\endgroup$
    – Docuemada
    Commented Jun 18, 2015 at 14:08
  • $\begingroup$ @LeonidShifrin may not see your comment. You can "ping" a user by adding the @ sign before their name, as I did at the beginning of this message. In case he was not interested in converting his comment into an answer, though, I'd urge you to do that yourself (self-answering is encouraged on Stack Exchange) so your question will have a full answer and will be more appealing to future users who encounter similar problems. $\endgroup$
    – MarcoB
    Commented Jun 19, 2015 at 2:57
  • $\begingroup$ Ok, posted an answer as requested. $\endgroup$ Commented Jun 19, 2015 at 9:33

1 Answer 1


Here is one way:

Query[Select[MemberQ[check, #[[2]]] &]] @ ds

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.