I am preparing data consisting of temperature and pressure values from each country in the world using the following code.

worldTemp = 
WeatherData[#, "Temperature"] & /@ CountryData["Countries"]];

worldPressure = 
WeatherData[#, "Pressure"] & /@ CountryData["Countries"]];

Data = 
MapThread[{Sequence @@ #1, #2} &, {worldPressure, worldTemp}];

How do you omit the rows containing {QuantityMagnitude[Missing["NotAvailable"]]}from the data set. Then I need to export the data into an excel file. Is that possible?

  • $\begingroup$ Select[Data, NumericQ[#[[1]]] && NumericQ[#[[2]]] &] ? $\endgroup$ – ulvi Apr 4 '18 at 0:40
  • $\begingroup$ No I tried that and it didn't work. $\endgroup$ – hwhorf Apr 4 '18 at 1:42
  • $\begingroup$ Some rows contain a missing value as well as a number. For example: {{na,2},{6,2},{5,na},{na,na}} $\endgroup$ – hwhorf Apr 4 '18 at 1:43
  • $\begingroup$ In 11.3 I only get pairs, either of numbers or of Missing messages, as members of Data. To keep only rows with entirely numeric data, you might try Select[Data, Apply[And, Map[NumericQ[#] &, Flatten[#]] &[#]] &] $\endgroup$ – ulvi Apr 4 '18 at 3:43
  • $\begingroup$ Have you seen DeleteMissing. It should do what you want, but whatever you do to get rid of the missing values, you should do it before trying to extract numeric values with QuantityMagnitude... $\endgroup$ – Albert Retey Apr 5 '18 at 12:00

Your Answer

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

Browse other questions tagged or ask your own question.