小编Ruu*_*uud的帖子

在2d阵列的Numpy卷垂直

如何(有效地)执行以下操作:

x = np.arange(49)
x2 = np.reshape(x, (7,7))

x2
array([[ 0,  1,  2,  3,  4,  5,  6],
       [ 7,  8,  9, 10, 11, 12, 13],
       [14, 15, 16, 17, 18, 19, 20],
       [21, 22, 23, 24, 25, 26, 27],
       [28, 29, 30, 31, 32, 33, 34],
       [35, 36, 37, 38, 39, 40, 41],
       [42, 43, 44, 45, 46, 47, 48]])
Run Code Online (Sandbox Code Playgroud)

从这里开始我想推出几件事.我想掷0,7,14,21等所以14来到顶部.然后与4,11,18,25等相同,所以39来到顶部.
结果应该是:

x2
array([[14,  1,  2,  3, 39,  5,  6],
       [21,  8,  9, 10, 46, 12, 13],
       [28, 15, 16, …
Run Code Online (Sandbox Code Playgroud)

python arrays numpy

6
推荐指数
2
解决办法
1963
查看次数

标签 统计

arrays ×1

numpy ×1

python ×1