4
$\begingroup$
testdataset = 
  Dataset[{ 
    <|"a" -> 3, "b_i" -> "y", "c" -> {3, 8, 9}, "d" -> "three", "student" -> "C"|>, 
    <|"a" -> 8, "b_i" -> "y", "c" -> {5, 6, 7}, "d" -> "twenty-six", "student" -> "L"|>, 
    <|"a" -> 9, "b_i" -> "x", "c" -> {1}, "d" -> "sixty-nine", "student" -> "Q"|>}
  ]

How can I extract all rows which contain an even number in "a", "c", "d" by (a) Select and (b) DeleteCases?

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Mar 13 '16 at 12:19
  • $\begingroup$ nice question... (I am currently trying to find books on data science and mathematica)... could you tell me what text book this is from? $\endgroup$ – Conor Cosnett Mar 13 '16 at 12:22
  • 1
    $\begingroup$ Actually, I'm not using a book. This is from a class I'm currently taking. $\endgroup$ – Ok_one Mar 13 '16 at 14:35
3
$\begingroup$

(a)

I found something similar here.

Use EvenQ inside Select to do it with the Select function:

testdataset[Select[EvenQ[#a] &]]
|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ For column "d": testdataset[Select[EvenQ[Interpreter["SemanticNumber"][#d]] &]] $\endgroup$ – J. M.'s technical difficulties Mar 13 '16 at 12:35
  • 1
    $\begingroup$ DeleteCases[testdataset, KeyValuePattern["a" -> _?OddQ]] $\endgroup$ – Kuba Nov 30 '16 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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