Answer the question
In order to leave comments, you need to log in
How to get a matrix from arrays?
Hello! The problem is this.
I have 2 arrays as input. It is necessary to get the (i-1)-th element for each element i of the first array (and then the second one). That is, so that the element i-1 should be in place i, the element i should be in place i+1, i +1 should be in place i+2, and so on. And the same with the second array. And then push these two arrays into the np.matrix matrix (the first array on the first line, the second array on the second). How is it rational to do this and why doesn't it work like that?
list1 = []
for i in range(len(array1)):
a1 = array1[i-1]
list1.append(a1)
array1 = np.array(list1)
list2 = []
for i in range(len(array2)):
a2 = array2[i-1]
list2.append(a2)
array2 = np.array(list2)
total_array = np.vstack((array1, array2))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question