import numpy as np
a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
# get length of flat array
a_length, = a.shape
# reshape array
#(column by row must respect number of elements)
b = a.reshape(( 2, a_length/2 ))
# assign array except last column to a variable
result = b[:,:-1]
print result
在您的简短示例中,您想要实现的目标可以通过重塑数组,然后删除最后一列来创建一个“间隙”。在
你的问题是否足够笼统?在
相关问题 更多 >
编程相关推荐