1
$\begingroup$

If I have the following lists:

Lists

How do I combine the two lists in order to plot points while ignoring the pairs where there is empty cells?. An example would be to get {0, 0.01}, {0, 0.03}, {0.127, 0},{0.285,1},{0.491,3},{0.865,10},(here is ignored the empty cell,10 pair),{0.951,30}.....etc.

Edit 1: Here's the list in mathematica form

{{0., 0.01}, {0., 0.03}, {0.12702, 0.1}, {0.284862, 0.3}, {0.330209, 
  1.}, {0.490592, 3.}, {0.864811, 10.}, {"", 10.}, {"", 
  10.}, {0.951112, 30.}, {"", 30.}, {"", 30.}, {0.924481, 100.}, {"", 
  100.}, {"", 100.}, {1.02702, 300.}, {"", 300.}, {"", 
  300.}, {1.12306, 1000.}, {"", 1000.}, {"", 1000.}, {1.061, 
  3000.}, {1.08021, 10000.}}

Edit 2: I tried Partition[Riffle[x,y],2] but this still pairs the empty cells and does not ignore them.

$\endgroup$
2
  • $\begingroup$ Please, always provide valid Mathematica code in copyable form. $\endgroup$ Apr 26 '20 at 23:12
  • 1
    $\begingroup$ Thank you! I haved added the list in Mathematica form $\endgroup$
    – John
    Apr 26 '20 at 23:20
1
$\begingroup$

Is this what you want?

list = {{0., 0.01}, {0., 0.03}, {0.12702, 0.1}, {0.284862, 
    0.3}, {0.330209, 1.}, {0.490592, 3.}, {0.864811, 10.}, {"", 
    10.}, {"", 10.}, {0.951112, 30.}, {"", 30.}, {"", 30.}, {0.924481,
     100.}, {"", 100.}, {"", 100.}, {1.02702, 300.}, {"", 300.}, {"", 
    300.}, {1.12306, 1000.}, {"", 1000.}, {"", 1000.}, {1.061, 
    3000.}, {1.08021, 10000.}};
DeleteCases[list, {"", _}]

It might be helpful for plotting to have the data ordered by the first entry. You can to this as follows:

SortBy[DeleteCases[list, {"", _}], First]
{{0., 0.01}, {0., 0.03}, {0.12702, 0.1}, {0.284862, 0.3}, {0.330209, 1.}, {0.490592, 3.}, {0.864811, 10.}, {0.951112, 30.}, {0.924481, 100.}, {1.02702, 300.}, {1.12306, 1000.}, {1.061, 3000.}, {1.08021, 10000.}}
$\endgroup$
5
  • $\begingroup$ Yes, thank you!. If you don't mind. Let's say that instead of blanket or empty cells, I had the number "7". Is there any way to use the same code to pair everything, except that the cells that contain the number 7?. Thanks again $\endgroup$
    – John
    Apr 26 '20 at 23:44
  • $\begingroup$ Have you tried to replace "" by "7"? Btw., I expect that you read the documentation of each now symbol in the post. The point of my post was to show you that the command DeleteCases exists. I can cook a meal for you, but you have t eat it yourself... $\endgroup$ Apr 26 '20 at 23:48
  • $\begingroup$ Hi Henrik. Yes, I have and it does not work. That's why I am asking. Anyways, I appreciate your help. $\endgroup$
    – John
    Apr 27 '20 at 0:29
  • $\begingroup$ Do you want to replace a "7", 7, "7.", or 7.? These are indeed four different things, and the floating point 7. is the hardest to come by... $\endgroup$ Apr 27 '20 at 0:34
  • $\begingroup$ Henry, I would like the number 7. I thought I would also be similar to your code replacing "" but it seems harder than that. $\endgroup$
    – John
    Apr 27 '20 at 0:46

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.