2

Variable with several arrays in it

I got this after using this code:

array1 = numpy.empty((0,4),int)

for a,b,c,d in something:

array1 = numpy.vstack([array1,[a,b,c,d]])

I am not sure why I am getting empty arrays. Is there a way to remove them?

Community
  • 1
  • 1
ILoveU3000
  • 65
  • 5
  • [see here](http://stackoverflow.com/questions/4842956/python-how-to-remove-empty-lists-from-a-list) – mkHun Feb 23 '17 at 07:08
  • 1
    Possible duplicate of [Python: How to remove empty lists from a list?](http://stackoverflow.com/questions/4842956/python-how-to-remove-empty-lists-from-a-list) – MD. Khairul Basar Feb 23 '17 at 07:08

1 Answers1

0
L = [[], [1, 4]]
C = filter(lambda x: x!=[], L)
print(C)

OUT:

[[4,2]]

ALTERNATIVE:

C = filter(lambda x: len(x) > 0, L)
print(C)

OUT:

[[4,2]]
Tony Tannous
  • 14,154
  • 10
  • 50
  • 86