Here an example:
a = np.array([[1, 2, 3,4], [], [1,2,0,9]])
print(a)
# array([list([1, 2, 3, 4]), list([]), list([1, 2, 0, 9])], dtype=object)
How to remove the empty element and return only:
array([[1, 2, 3, 4], [1, 2, 0, 9]], dtype=object)
A simple for loop iteration over array and computing length will be enough to get rid of empty elements.
a = np.array([[1,2,3,4],[],[5,6,7,8]]
output = []
for elem in a:
if elem:
output.append(elem)
output= np.array(output)
output? Compared to the original a ?