Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arr = np.array([[1,2,3],[4,5,6],[7,8,9]])
- array([[0, 1, 2],
- [3, 4, 5],
- [6, 7, 8]])
- (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)
- for row in range(arr.shape[0]):
- for col in range(arr.shape[1]):
- print (row + 0.5, col + 0.5)
- import numpy as np
- arr = np.arange(3 * 3).reshape(3, 3)
- grid = np.mgrid[:arr.shape[0], :arr.shape[1]] + 0.5
- print(grid.reshape(2, grid.size // 2).T)
Add Comment
Please, Sign In to add comment