Drop commas after deleting "Indeterminate" values?

Dear All,

I am currently struggling with an issue for which I cannot find a concrete answer within the community. I am currently working with a dataset, where I got Indetermiante values. I droped these by using the following code:

data2= data/. Indeterminate -> ""

Now I have the problem that my data look like this: 0.145596, 0.123875, 0.066587,,,,, 0.102394, -0.418984, -0.422966, -0.50856, -0.161867,,, -0.470506, -0.463086, 0.349094, 0.633164

However, I would get rid of all Indeterminate values or better, get rid of the commas, somehow just getting the values of the list. Can someone please help me and tell me how to flatten the data (delete the missings)?

Thank you in advance!

Best regards
Alex

Dear all, sorry to bother you. I found a solution for myself, which was obviously pretty simple. I used the function DeleteCases[data, ""] and solved it. Hence, please disregard my posting.

If data is a list, and it seems so, you can use

data /. Indeterminate → Nothing

or

data /. Indeterminate → Sequence[]

or

DeleteCases[data, Indeterminate]

etc.

Your method does not work because an empty string “” is not special, it will be part of your list as any other expression.

You’re not dropping them, you’re replacing them with empty strings (“”). To delete them use e.g. DeleteCases:

DeleteCases[data,Indeterminate]

Okay, thank you very much for your immediate reply! :slight_smile:

Just be careful, in general, with “replacing with Sequence[]”. Sequence will not be directly evaluated:

b = {1, 2, 3, 4};
b[[1]] = Sequence[];
b[[1]] = Sequence[];
b[[1]] = Sequence[];
?b
b

This does not result in a list of length 1, but rather length 3. The first element is dropped only once, not thrice. You need intermediate evaluations:

b = {1, 2, 3, 4};
b[[1]] = Sequence[];
b = b;
b[[1]] = Sequence[];
b = b;
b[[1]] = Sequence[];
b = b;
b

Therefore I would strongly advice to use DeleteCases over replacing with Nothing or Sequence. And note that Nothing only works in Lists not in objects with different heads…

I’m replacing and you are Set-ting and this is not a problem in my approach as everything gets evaluated anyway.

But that is a good point for new users.

And yes, for a vector, DeleteCases should be away to go.

p.s. [?] Understand sequence behaviour?