我有numpy数组,我想根据其索引号选择一些值。我正在使用Python3.6
例如:
np.array:
index#
[0]
[1] + + + + + + + + + + + + + + + + + + + +
[2] + I want to selct + + I don't want to select:
[3] + the indexs: + + [0]
[4] + [2] + + [10]
[5] + [4] + + Or any between
[6] + [6] + +
[7] + [8] + + + + + + + + + + +
[8] …Run Code Online (Sandbox Code Playgroud) 我正在使用Python 3.6。
我正在尝试这样做:
import numpy as np
def run_11(x):
return x+1
kk = np.arange(1, 17)
for i in range (kk):
ind = run_11(i)
print (i)
print (ind)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
类型错误:只有整数标量数组可以转换为标量索引
我不明白为什么以及如何解决它。任何建议将不胜感激