2

I hav these arrays and i want to loop over to get each time one row but over theses three ,can someine help

first time get [99.83765958, 98.95138005, 97.81793785]
then [ 0.05817715,  0.36399226,  0.75565525]
then [ 0.05308382,  0.34710437,  0.72242136]  

b1 = array([[99.83765958, 98.95138005, 97.81793785],
   [91.18638412, 85.0394929 , 60.81349713],
   [49.40130762, 42.88999627, 37.3274071 ],
   [34.07199473, 32.66451319, 29.18990008],
   [28.08612149, 28.44254854, 28.13146169]])


b2 = array([[ 0.05817715,  0.36399226,  0.75565525],
   [ 3.061885  ,  5.18802406, 13.69974769],
   [17.63566276, 19.97480026, 21.89124576],
   [22.65164468, 23.227042  , 24.34795284],
   [24.71503785, 24.62888505, 24.82418201]])

b3 = array([[ 0.05308382,  0.34710437,  0.72242136],
   [ 2.89814597,  4.92794704, 12.92336549],
   [16.72359198, 18.81699616, 20.68106204],
   [21.93477086, 22.32555405, 23.48848985],
   [23.86645895, 23.78848383, 23.87828935]])

1 Answer 1

1

You can use zip function:

for row in zip(b1, b2, b3):
    for elem in row:
        print(elem)
Sign up to request clarification or add additional context in comments.

8 Comments

yes, but if i want to loop over them all together not just row[0], row[1], row[2] becaus i want to use them a function
What do you mean by "loop over them all together". For the loop I've posted the row at each iteration will be the 1D array with 3 elements, just like you specified -> array([99.83765958 98.95138005 97.81793785]), at the second iteration array([0.05817715, 0.36399226, 0.75565525]) and so on. If that is not what you want, then please explain more specifically.
yes but i dont every time to write 0,1,2,3,4, ...30 to finsih row[0] how can i specify it in an index
row[i] so it loops over the 3 arrays together row by row 5 times but i dont know how to do it
Do inner loop for elem in row. Otherwise, it is hard to understand what do you want.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.