I managed to put the arrays in for loop and, depending on the condition, select the values I need. From these selected values I try to choose the highest value from the matrix a and b. Unfortunately, somehow I miss some syntax.
my code
a=np.array([0, 0, 0, 1, 1, 1, 2, 4,2, 2])
b=np.array([0, 1, 2, 0, 1, 2, 0, 1, 2,5])
max_b=b[0]
for (j), (k) in zip(a,b):
#print(j,k)
if j>=2 and k>=1:
print(j,'a')
print(k,'b')
output:
4 a
1 b
2 a
2 b
2 a
5 b
i need : From these numbers I need to choose the largest number from j and k
4 a
5 b
I also created the code specifically to get the highest value in the loop from one matrix without other conditions to make it work better, but I can't incorporate it correctly into my code
maxv=a[0]
for i in a:
if i > maxv:
maxv=i
print(maxv)
This is my attempt, but it is stupid
a=np.array([0, 0, 0, 1, 1, 1, 2, 4,2, 2])
b=np.array([0, 1, 2, 0, 1, 2, 0, 1, 2,5])
#max_b=b[0]
for (j), (k) in zip(a,b):
#print(j,k)
if j>=2 and k>=1:
#print(j,'a')
# print(k,'b')
max_a=j
max_b=k
if j > max_a:
max_a=k
print(max_a)
Can you advise me how it could work?