0

I have an array looking like this:

[array([268.95504761,  -4.17598009, 404.12548828])
array([268.9979248 ,  -4.15205622, 404.09713745])
array([269.00808716,  -4.14346504, 404.07214355])
array([280.63632202,  -8.46781635, 398.50079346])
None 
None 
array([281.69018555,  -9.98347282, 390.9984436 ])]

How do I remove the None lines? All method I found assumed the regular case of a normal 2D array containing some None elements.

1
  • What methods have you tries? Remember this is a 1d object dtype array (or a list], not a 2d numeric array. Commented Aug 12, 2019 at 14:33

1 Answer 1

3
[elem for elem in my_list if elem is not None]

Simple list-comprehension? Correct me if I misunderstood you :-)

Sign up to request clarification or add additional context in comments.

4 Comments

elem is not None
For comparison with singletons (like None), elem is not None is the proper way to check. stackoverflow.com/questions/1504717/…
The None-type object is a great thing isn't it (;
thanks, that is exactly what I need! Sometimes you just don't see the easy solutions :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.