python how to copy a 2d array leaving out last column

Solutions on MaxInterview for python how to copy a 2d array leaving out last column by the best coders in the world

showing results for - "python how to copy a 2d array leaving out last column"
María
29 Jan 2016
1In [1]: import numpy as np
2
3In [2]: H = np.meshgrid(np.arange(5), np.arange(5))[0]
4
5In [3]: H
6Out[3]: 
7array([[0, 1, 2, 3, 4],
8       [0, 1, 2, 3, 4],
9       [0, 1, 2, 3, 4],
10       [0, 1, 2, 3, 4],
11       [0, 1, 2, 3, 4]])
12
13In [4]: Hsub = H[1:-1,1:-1]
14
15In [5]: Hsub
16Out[5]: 
17array([[1, 2, 3],
18       [1, 2, 3],
19       [1, 2, 3]])
20