I start with a numpy array of numpy arrays, where each of the inner numpy arrays can have different lengths. An example is given below:
import numpy as np
a = np.array([1,2,3])
b = np.array([4,5])
c = np.array([a, b])
print c
[[1 2 3] [4 5]]
I'd like to be able to perform a boolean operation on every element in every element in array c, but when I try to I get the following value error:
print c > 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()
I'd like to be able to get the result:
[[True True True] [True True]]
Without using a for loop or iterating on the outer array. Is this possible, and if so, how can I accomplish it?