I am attempting to use AstronomicalData and DeleteCases together to remove invalid cases of two properties while listing the corresponding name which the data belongs to.

I can only selectively choose one of the two properties in which to remove invalid cases from.

An example of two selected properties with the first property being filtered;

 AstronomicalData["Exoplanet", P1], AstronomicalData["Exoplanet", P2], AstronomicalData["Exoplanet"]

The issue is having a limitation of defining either P1 or P2 as the chosen property to remove invalid cases from. I have tried various ways of correcting this and can't apply it to both properties.

I can switch which property it acts upon by swapping the slot _Missing is defined in like this;


Defining both slots doesn't apply the function to either individual property like this;


How can I achieve being able to filter the results where if either property has an invalid value the data is dismissed?

  • 1
    $\begingroup$ {___, _Missing, ___} this should delete any row wit Missing value. You can use FreeQ/MemberQ with Pick or with Sow+Reap too. $\endgroup$
    – Kuba
    Jan 10 '14 at 13:32
  • $\begingroup$ @Kuba That solution is working fine. I'm unfamiliar with Sow+Reap, I'll have to look further into them. Do you mind mentioning why the solution only works while _Missing is defined in #2? $\endgroup$ Jan 10 '14 at 13:42
  • 1
    $\begingroup$ BlankNullSequence is the key, take a look at documentation. $\endgroup$
    – Kuba
    Jan 10 '14 at 13:44

I have not found good duplicate, and there is none in so maybe one can find this useful.

data = RandomChoice[{1, 2, 3, 4, Missing[]}, {100, 3}];

n = 100;

DeleteCases[data, {___, _Missing, ___}]~Do~{n} // Timing // First
Cases[data, {_?NumberQ ..}]~Do~{n} // Timing // First
Pick[data, FreeQ[#, _Missing] & /@ data, True]~Do~{n} // Timing // First
Reap[Map[If[FreeQ[#, _Missing], Sow[#]] &, data]][[2, 1]]~Do~{n} // Timing // First
data /. {___, _Missing, ___} -> Sequence[]~Do~{n} // Timing // First




  • $\begingroup$ +1, don't know why you made it community wiki! My favorite version is Missing, it is data /. {___, _Missing, ___} -> Sequence[]~Do~{n} // Timing // First $\endgroup$
    – C. E.
    Jan 10 '14 at 19:49
  • $\begingroup$ @Anon :) feel free to add an answer :) About wiki, I don't know, I usually do this when I feel this is a duplicate and the answer is not really the best one. :) $\endgroup$
    – Kuba
    Jan 10 '14 at 19:58
  • $\begingroup$ Alright, maybe it's the right thing to do. It does encourage others to pitch in, but I'm so unused to it I didn't know how to interpret it. $\endgroup$
    – C. E.
    Jan 10 '14 at 20:18
  • $\begingroup$ Standalone {___,_Missing,___} works fine, a bit less bulky than the alternatives. As there is limited data I don't think in this instance the alternatives will provide any benefit, unless I'm wrong, I will test them all to find any benefits nonetheless. $\endgroup$ Jan 13 '14 at 15:11

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.