Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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;

DeleteCases[Transpose[{
 AstronomicalData["Exoplanet", P1], AstronomicalData["Exoplanet", P2], AstronomicalData["Exoplanet"]
 }],{_Missing,_,_}],

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;

{_Missing,_,_}
{_,_Missing,_}

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

{_Missing,_Missing,_}

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

share|improve this question
1  
{___, _Missing, ___} this should delete any row wit Missing value. You can use FreeQ/MemberQ with Pick or with Sow+Reap too. –  Kuba Jan 10 at 13:32
    
@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? –  Ashley James Jan 10 at 13:42
1  
BlankNullSequence is the key, take a look at documentation. –  Kuba Jan 10 at 13:44
add comment

1 Answer 1

up vote 4 down vote accepted

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
0.004289

0.009231

0.014014

0.022367

0.000167
share|improve this answer
    
+1, don't know why you made it community wiki! My favorite version is Missing, it is data /. {___, _Missing, ___} -> Sequence[]~Do~{n} // Timing // First –  Pickett Jan 10 at 19:49
    
@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. :) –  Kuba Jan 10 at 19:58
    
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. –  Pickett Jan 10 at 20:18
    
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. –  Ashley James Jan 13 at 15:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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