我尝试仅向数组indx
的右侧添加,但我希望保留数组的左侧。我怎样才能得到Expected Output
。
代码:
import numpy as np
number = 3
indx=np.array([[ 0, 1],
[ 1, 765],
[ 0, 4355],
[ 1, 9364],
[ 0, 12110],
[ 1, 15233],
[ 0, 16246],
[ 1, 18889]])
indx = indx[:,1] + number
输出:
[ 4 768 4358 9367 12113 15236 16249 18892]
预期输出
[[ 0 4]
[ 1 768]
[ 0 4358]
[ 1 9367]
[ 0 12113]
[ 1 15236]
[ 0 16249]
[ 1 18892]]
发布于 2021-08-25 15:15:15
import numpy as np
indx=np.array(
[[ 0, 1],
[ 0, 4355],
[ 1, 9364],
[ 0, 12110],
[ 1, 15233],
[ 0, 16246],
[ 1, 18889]])
indx[:,1] = indx[:,1] + 3
print(indx)
[[ 0 4]
[ 1 768]
[ 0 4358]
[ 1 9367]
[ 0 12113]
[ 1 15236]
[ 0 16249]
[ 1 18892]]
https://stackoverflow.com/questions/68930710
复制相似问题