У меня есть матрица с некоторыми значениями.Я хочу получить m, n позиций каждого значения в отдельной матрице.
import numpy as np
a = np.zeros((3,3)) #Creating "a" matrix with all zeros
vals = [22,34,43,56,37,45] # the values that i want to add to the matrix "a"
pos = [(0,1),(0,2),(1,0),(1,2),(2,0),(2,1)] # Corresponding positions of the above given values
rows, cols = zip(*pos) # This code is to assign the given values in the correct position
a[rows, cols] = vals
print (a)
output =
[[(0,0) (0,1) (0,2)]
[(1,0) (1,1) (1,2)]
[(2,0) (2,1) (2,2)]]
, пожалуйста, помогите мне.
Я хочу получить матрицу положения (m, n) любой матрицы (m, n)