I want to compare all elements of a two-dimensional list array with a float x. The result should be a list: b = [[True, False,...],...]. I tried it like that:
import numpy as np
array = [[a1,a2,...], [a3,a4,...],...,]
x = 2.0
b = np.array([a >= x for a in array])`
"TypeError: '>=' not supported between instances of 'list' and 'float'"
When I use a one-dimensional list it works fine.
Thanks in advance!!
np.array([[a1,a2,...], [a3,a4,...],...,] )and if you still get the error, that means your list elements are ragged (irregular in size).b = np.array([a >= x for a in array]), sincearrayis multidimensional,ais a list. So in this case you are comparinga(a list) withx(a float).b = np.array(array) >= x?array, sayarray[:2,:2]?