There is an arr array with data (in fact, they are not important).
arr = np.array([[1,2,3],[4,5,6],[7,8,9]]) array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) It is necessary to obtain a list of coordinates of the center of each element of the array. It is assumed that the length of each cell is equal to 1. That is, you need to get the following:
(0.5, 0.5) (0.5, 1.5) (0.5, 2.5) (1.5, 0.5) (1.5, 1.5) (1.5, 2.5) (2.5, 0.5) (2.5, 1.5) (2.5, 2.5) I do this:
for row in range(arr.shape[0]): for col in range(arr.shape[1]): print (row + 0.5, col + 0.5) Actually a question. How to get rid of nested for each other? I feel - for sure there is some simple method from Numpy .