I have two numpy arrays x
and y
x = numpy.array([1,2,3,4,5])
y = numpy.array([1,3,5,7])
z = func(x,y) # z = [2,2,3,3,4]
is there a function func
that will return the above. Eg the index of the first element in y that is greater than 1 (first element in x) is 2 so z[0]=2
Looking for a one liner vectorized way to do this if it exists. Something that is agnostic to the actual comparison function (less than, greater than, leq, geq, etc)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.