这是我的密码
import numpy as np
contrainte1= 1080*0.65 # minutes tous les jours
contrainte2= 720*0.55 # minutes du lundi au vendredi
X=np.array([[9, 48],[12, 46],[14, 41],[12, 45],[6, 50],[10, 48],[25, 12],[26, 15],[30, 10],[31, 16],[40, 10],[41, 12],[35, 18],[35, 19],[30, 21],[28, 21],[25, 24],[21, 28],[22, 30],[25, 26],[26, 25],[30, 20],[32, 16],[35, 12]])<
#La première position représente la contrainte 1
#La deuxième position représente la contraire 2
# contrainte 1
for i in X[-19:]:
print(i)
for y in #This is where I need help
我想对每个数组(I)执行一个循环,其中我将对数组第一部分中的每个值进行求和。每个例子,我希望能够用np.sum()计算9+12+14….+35的和
当我像SciPy向我展示的那样尝试索引时,我似乎找不到做我想做的事情的技术。或者我就是不懂(语言障碍)
谢谢
如果我理解你的意思,你只想对第一列中的元素求和?所需要的只是一点索引和
sum
:相关问题 更多 >
编程相关推荐